Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Merge with latest from upstream
All conflicts resolved
  • Loading branch information
Seth Kips committed Mar 21, 2014
2 parents 3571b1b + dce28f3 commit 7862e7e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ai.eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function evalGameState(game) {
c.status.adrenaline = 1;
}
// todo SoFr
return atk * (fshactive == Actives.evade100 ? 1 - fsh.status.charges / 6 : fshactive == Actives.evade50 ? .5 : fshactive == Actives.evade40 ? .4 : 1) * (((fsh && fsh.passives.reflect && c.status.psion) || c.owner.foe.sosa) ? -1 : 1);
return atk * (fshactive == Actives.evade100 ? 1 - fsh.status.charges / 6 : fshactive == Actives.evade50 ? .5 : fshactive == Actives.evade40 ? .6 : fshactive == Actives.chaos ? .75 : 1) * (((fsh && fsh.passives.reflect && c.status.psion) || c.owner.foe.sosa) ? -1 : 1);
}

function evalthing(c) {
Expand Down
42 changes: 41 additions & 1 deletion etg.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,43 @@ Player.prototype.spend = function(qtype, x) {
}
return true;
}
function expectedDamage(player) {
function truetrueatk(c) {
var fsh = c.owner.foe.shield;
var tatk = c.trueatk(), fshactive = fsh && fsh.active.shield;
var momentum = atk < 0 || c.status.momentum || c.status.psion;
var dr, atk;
if (momentum) {
atk = tatk;
} else {
dr = fsh ? fsh.truedr() : 0;
atk = Math.max(tatk - dr, 0);
if (fshactive == Actives.weight && c instanceof Creature && c.truehp() > 5) {
atk = 0;
}
}
if (c.status.frozen || c.status.delayed)
atk = 0;
if (atk > 0 && c.status.adrenaline) {
var attacks = countAdrenaline(tatk);
while (c.status.adrenaline < attacks) {
c.status.adrenaline++;
atk += momentum ? c.trueatk() : Math.max(c.trueatk() - dr, 0);
}
c.status.adrenaline = 1;
}
// todo SoFr
return atk * (fshactive == Actives.evade100 ? 0 : fshactive == Actives.evade50 ? .5 : fshactive == Actives.evade40 ? .6 : fshactive == Actives.chaos ? .75 : 1) * (fsh && fsh.passives.reflect && c.status.psion ? 0 : (c.owner.foe.sosa ? -1 : 1));
}
totalDamage = 0;
for (var i = 0; i < 23; i++) {
if (player.creatures[i])
totalDamage += truetrueatk(player.creatures[i]);
}
if (player.weapon) totalDamage += truetrueatk(player.weapon);
if (player.foe.status.poison) totalDamage += player.foe.status.poison;
return totalDamage;
}
Player.prototype.endturn = function(discard) {
this.game.ply++;
if (discard != undefined){
Expand Down Expand Up @@ -410,6 +447,7 @@ Player.prototype.endturn = function(discard) {
this.flatline = this.silence = false;
this.foe.precognition = this.foe.sanctuary = false;
this.game.turn = this.foe;
this.expectedDamage = expectedDamage(this);
}
Player.prototype.procactive = function(name, func) {
if (!func){
Expand Down Expand Up @@ -775,6 +813,7 @@ Thing.prototype.useactive = function(t) {
this.active.cast(this, t);
}else new TextEffect("Evade", tgtToPos(t));
this.owner.spend(castele, cast);
this.owner.expectedDamage = expectedDamage(this.owner);
}
Player.prototype.defstatus = Thing.prototype.defstatus = function(key, def){
if (!(key in this.status)){
Expand Down Expand Up @@ -889,7 +928,8 @@ CardInstance.prototype.useactive = function(target){
}
}else if (card.type == CreatureEnum){
new Creature(card, owner).place();
}else console.log("Unknown card type: "+card.type);
} else console.log("Unknown card type: " + card.type);
owner.expectedDamage = expectedDamage(owner);
}
function countAdrenaline(x){
return 5-Math.floor(Math.sqrt(Math.abs(x)));
Expand Down
30 changes: 19 additions & 11 deletions ui.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,9 @@ function aiFunc(){
return ["endturn", worstcards[Math.floor(Math.random()*worstcards.length)]];
}else return ["endturn"];
}

function doubleDeck(deck) {
return deck.slice(0, deck.length - 2).concat(deck);
}
function mkDemigod() {
if (user) {
if (user.gold < 20) {
Expand All @@ -688,7 +690,7 @@ function mkDemigod() {
"710 710 710 710 710 710 710 710 710 710 710 710 710 710 72i 72i 72i 72i 71l 71l 71l 71l 717 717 717 71b 71b 71b 711 711 7t7 7t7 7t7 7t7 7t7 7t7 7t9 7t9 7t9 7ti 7ti 7ti 7ti 7ta 7ta 8pt",
"778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 77g 77g 77g 77g 77g 77g 77q 77q 77h 77h 77h 77h 77h 77b 77b 77b 7q4 7q4 7q4 7ql 7ql 7ql 7ql 7ql 7q3 7q3 8ps"]
var deck = demigodDeck[Math.floor(Math.random() * demigodDeck.length)].split(" ");
deck = deck.slice(0,deck.length-2).concat(deck);
deck = doubleDeck(deck);
var urdeck = getDeck();
if ((user && (!user.deck || user.deck.length < 31)) || urdeck.length < 11){
startEditor();
Expand Down Expand Up @@ -1075,11 +1077,11 @@ function startMenu() {
if (!user) toggleB(baia, bshop, bupgrade, binfoa, btopa, blogout, bdelete);

//only display if user is logged in
if (user){
if (user) {
tgold.position.set(770, 101);
igold.visible = true;

if (user.oracle){
if (user.oracle){
// todo user.oracle should be a card, not true. The card is the card that the server itself added. This'll only show what was added
delete user.oracle;
var card = PlayerRng.randomcard(false,
Expand Down Expand Up @@ -2064,6 +2066,7 @@ function startMatch(){
maybeSetText(hptext[j], game.players[j].hp + "/" + game.players[j].maxhp);
maybeSetText(poisontext[j], game.players[j].status.poison + (game.players[j].neuro?"psn!":"psn"));
maybeSetText(decktext[j], game.players[j].deck.length + "cards");
maybeSetText(damagetext[j], game.players[j].foe.expectedDamage ? "Next HP-loss:" + game.players[j].foe.expectedDamage : "");
}
}
gameui = new PIXI.Stage(0x336699, true);
Expand Down Expand Up @@ -2170,7 +2173,8 @@ function startMatch(){
var shiesprite = [new PIXI.Sprite(nopic), new PIXI.Sprite(nopic)];
var marksprite = [new PIXI.Sprite(nopic), new PIXI.Sprite(nopic)];
var quantatext = [new PIXI.DisplayObjectContainer(), new PIXI.DisplayObjectContainer()];
var hptext = [new PIXI.Text("", {font: "18px Dosis"}), new PIXI.Text("", {font: "18px Dosis"})];
var hptext = [new PIXI.Text("", { font: "18px Dosis" }), new PIXI.Text("", { font: "18px Dosis" })];
var damagetext = [new PIXI.Text("", { font: "14px Dosis" }), new PIXI.Text("", { font: "14px Dosis" })];
var poisontext = [new PIXI.Text("", {font: "16px Dosis"}), new PIXI.Text("", {font: "16px Dosis"})];
var decktext = [new PIXI.Text("", {font: "16px Dosis"}), new PIXI.Text("", {font: "16px Dosis"})];
for (var j=0; j<2; j++){
Expand Down Expand Up @@ -2319,14 +2323,17 @@ function startMatch(){
hptext[j].anchor.set(.5, .5);
poisontext[j].anchor.set(.5, .5);
decktext[j].anchor.set(.5, .5);
damagetext[j].anchor.set(.5, .5);
quantatext[j].position.set(j?792:0, j?100:308);
hptext[j].position.set(50, 560);
poisontext[j].position.set(50, 580);
decktext[j].position.set(50, 540);
damagetext[j].position.set(50, 520);
if (j){
reflectPos(hptext[j]);
reflectPos(poisontext[j]);
reflectPos(decktext[j]);
reflectPos(damagetext[j]);
}
var child;
for(var k=1; k<13; k++){
Expand Down Expand Up @@ -2355,6 +2362,7 @@ function startMatch(){
gameui.addChild(hptext[j]);
gameui.addChild(poisontext[j]);
gameui.addChild(decktext[j]);
gameui.addChild(damagetext[j]);
}
var fgfx = new PIXI.Graphics();
gameui.addChild(fgfx);
Expand Down Expand Up @@ -2466,12 +2474,13 @@ cmds.cast = function(bits) {
var socket = io.connect(location.hostname, {port: 13602});
socket.on("pvpgive", initGame);
socket.on("tradegive", initTrade)
socket.on("foearena", function(data){
socket.on("foearena", function (data) {
var deck = etg.decodedeck(data.deck);
deck = doubleDeck(deck);
chatArea.value = data.name + ": " + deck.join(" ");
initGame({ first:data.first, deck:deck, urdeck:getDeck(), seed:data.seed, hp:data.hp, cost:data.cost }, aievalopt.checked?aiEvalFunc:aiFunc);
initGame({ first:data.first, deck:deck, urdeck:getDeck(), seed:data.seed, hp:data.hp, cost:data.cost, foename:data.name }, aievalopt.checked?aiEvalFunc:aiFunc);
game.arena = data.name;
game.gold = 20;
game.gold = 10;
game.cost = 10;
});
socket.on("arenainfo", startArenaInfo);
Expand Down Expand Up @@ -2603,14 +2612,13 @@ function loginClick(){
}else{
user.deck = etg.decodedeck(user.deck);
deckimport.value = user.deck.join(" ");
if (user.pool) {
if (user.pool || user.pool == "") {
user.pool = etg.decodedeck(user.pool);
}
else
user.pool = [];
if (user.starter) {
user.starter = etg.decodedeck(user.starter);
}
console.log(user.pool);
startMenu();
}
}else if (this.status == 404){
Expand Down

0 comments on commit 7862e7e

Please sign in to comment.