moves all api logic inside PlayerView, found weird bug in unpack_gold_value (floating error)
This commit is contained in:
@@ -11,7 +11,20 @@ export default {
|
||||
},
|
||||
notifications: [],
|
||||
loot: [],
|
||||
claims: {},
|
||||
}},
|
||||
created () {
|
||||
api.fetch("claims", "GET", null)
|
||||
.then(r => {
|
||||
for (var idx in r.value) {
|
||||
var claim = r.value[idx];
|
||||
if (!(claim.player_id in this.claims)) {
|
||||
this.$set(this.claims, claim.player_id, []);
|
||||
}
|
||||
this.claims[claim.player_id].push(claim.loot_id);
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
parseUpdate (update) {
|
||||
if (update.Wealth) {
|
||||
@@ -21,16 +34,24 @@ export default {
|
||||
this.player.gp += w.gp;
|
||||
this.player.pp += w.pp;
|
||||
}
|
||||
if (update.ItemAdded) {
|
||||
else if (update.ItemAdded) {
|
||||
var i = update.ItemAdded;
|
||||
this.loot.push(i);
|
||||
}
|
||||
if (update.ItemRemoved) {
|
||||
else if (update.ItemRemoved) {
|
||||
var i = update.ItemRemoved;
|
||||
this.loot.splice(this.loot.indexOf(i), 1);
|
||||
}
|
||||
if (update.ClaimAdded || update.ClaimRemoved) {
|
||||
console.error("cannot handle claim !", update);
|
||||
else if (update.ClaimAdded) {
|
||||
var c = update.ClaimAdded;
|
||||
this.claims[c.player_id].push(c.loot_id);
|
||||
}
|
||||
else if (update.ClaimRemoved) {
|
||||
var c = update.ClaimRemoved;
|
||||
this.claims[c.player_id].splice(
|
||||
this.claims[c.player_id].indexOf(c.loot_id),
|
||||
1
|
||||
);
|
||||
}
|
||||
},
|
||||
call (resource, method, payload) {
|
||||
@@ -79,7 +100,8 @@ export default {
|
||||
withdrawClaim: this.withdrawClaim,
|
||||
buyItems: this.buyItems,
|
||||
sellItems: this.sellItems,
|
||||
}
|
||||
},
|
||||
claims: this.claims,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user