###  Author

Active members:
antiaverage(1)

#### antiaverage • Administrator
•        • • Posts: 1446
• Reputation Power: 35
•       • HTML5-hipster-sloth.bunchie();
• Awards:         ##### Level 0 and Level 1 Deckshttp://elementscommunity.org/forum/index.php?topic=59625.msg1206213#msg1206213
« on: September 19, 2015, 11:44:05 AM »
People were asking about how the decks are randomly generated for Level 0 and Level 1 opponents. I will post the code from the game here, and maybe at some point I'll write up a simple explanation of how it works.

Level 0:
Spoiler for Hidden:
// When you select Level 0
if (level == 0) {
lost = lost + 1;
}

// Generating the Level 0 deck
if (level == 0) {
firstpillar = 0;
firstcreature = 0;
firstskill = 0;
firstattack = 0;
pvpuser = "level 0";
_root.guide.gotoAndPlay("firstcard");
decke = "";
for (i = 0; i < 35; i++) {
ran = Math.floor(Math.random() * deckan);
temp = decka.slice(4 * ran, 4 * (ran + 1));
decke = decke + temp;
for (j = 0; j < 3; j++) {
if (temp.slice(0, 1) == "0") {
temp = temp.slice(1, 4);
}
}
tempelement = Math.floor(Number(temp) / 100);
if (Math.random() > 0.200000 && tempelement > 0) {
temp = tempelement * 100;
if (temp < 1000) {
temp = "0" + temp;
}
i = i + 1;
decke = decke + temp;
}
}
decke = decke + "0002";
decken = i + 1;
}
if (level == 0) {
hpemax = 50;
}

// Winning against Level 0
if (level == 0) {
addele(1);
fhc = fhc + 1;
gained = 1;
addwon(1);
addsco(1);
lost = lost - 1;
quest1 = 1;
}
if (hp >= hpmax && level != "pvp" && level != -4) {
addele(gained);
fhc = fhc + gained;
gained = gained * 2;
addsco(5 * level);
gratz.gotoAndPlay(2);
}
if (kong == 1 && score < 1000000) {
kongregate.stats.submit("won", won);
kongregate.stats.submit("score", score);
kongregate.stats.submit("lost", lost);
}

Level 1:
Spoiler for Hidden:
// When you select Level 1
if (level == 1) {
lost = lost + 1;
addsco(-2);
}

// Generating the Level 1 deck
if (level == 1) {
pvpuser = "level 1";
decke = "";
for (i = 0; i < 49; i++) {
ran = Math.floor(Math.random() * deckan);
temp = decka.slice(4 * ran, 4 * (ran + 1));
decke = decke + temp;
for (j = 0; j < 3; j++) {
if (temp.slice(0, 1) == "0") {
temp = temp.slice(1, 4);
}
}
tempelement = Math.floor(Number(temp) / 100);
if (Math.random() > 0.500000 && tempelement > 0) {
temp = tempelement * 100;
if (temp < 1000) {
temp = "0" + temp;
}
i = i + 1;
decke = decke + temp;
}
}
decke = decke + "0002";
decken = i + 1;
}

// Winning against Level 1
if (level == 1) {
gained = 1 + Math.floor(hp / 25);
addele(2 + gained);
fhc = fhc + 2 + gained;
addwon(1);
addsco(2 + gained);
adjcha(1);
lost = lost - 1;
quest4 = 1;
if (kong == 1) {
kongregate.stats.submit("lvl1", 1);
}
}
if (hp >= hpmax && level != "pvp" && level != -4) {
addele(gained);
fhc = fhc + gained;
gained = gained * 2;
addsco(5 * level);
gratz.gotoAndPlay(2);
}
if (kong == 1 && score < 1000000) {
kongregate.stats.submit("won", won);
kongregate.stats.submit("score", score);
kongregate.stats.submit("lost", lost);
}
« Last Edit: September 19, 2015, 12:01:20 PM by antiaverage »
Developer of http://dek.im - a Deck Image generator with rollover to view full cards, current to version 1.327

Thanks to Amashi for my avatar!

anything
blarg: Amashi