Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 738325: Players can now loot all items stacked on the same cell

commit 8d5bc6a2b02fd793e55381f57ac5f5b7fb55e24e 1 parent bc991a3
@sork sork authored
View
5 client/js/character.js
@@ -248,11 +248,6 @@ define(['entity', 'transition', 'timer'], function(Entity, Transition, Timer) {
onStep: function(callback) {
this.step_callback = callback;
},
-
- /*
- onBlocked: function(callback) {
- this.blocked_callback = callback;
- },*/
isMoving: function() {
return !(this.path === null);
View
34 client/js/game.js
@@ -448,7 +448,7 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
removeItem: function(item) {
if(item) {
- this.itemGrid[item.gridY][item.gridX] = null;
+ this.removeFromItemGrid(item, item.gridX, item.gridY);
this.removeFromRenderingGrid(item, item.gridX, item.gridY);
delete this.entities[item.id];
} else {
@@ -494,7 +494,7 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
for(var i=0; i < this.map.height; i += 1) {
this.itemGrid[i] = [];
for(var j=0; j < this.map.width; j += 1) {
- this.itemGrid[i][j] = null;
+ this.itemGrid[i][j] = {};
}
}
log.info("Initialized the item grid.");
@@ -538,6 +538,12 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
delete this.entityGrid[y][x][entity.id];
}
},
+
+ removeFromItemGrid: function(item, x, y) {
+ if(item && this.itemGrid[y][x][item.id]) {
+ delete this.itemGrid[y][x][item.id];
+ }
+ },
removeFromPathingGrid: function(x, y) {
this.pathingGrid[y][x] = 0;
@@ -596,7 +602,7 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
}
}
if(entity instanceof Item) {
- this.itemGrid[y][x] = entity;
+ this.itemGrid[y][x][entity.id] = entity;
}
this.addToRenderingGrid(entity, x, y);
@@ -1705,11 +1711,11 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
}
var entities = this.entityGrid[y][x],
- entity;
+ entity = null;
if(_.size(entities) > 0) {
entity = entities[_.keys(entities)[0]];
} else {
- entity = this.itemGrid[y][x];
+ entity = this.getItemAt(x, y);
}
return entity;
},
@@ -1742,7 +1748,23 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
if(this.map.isOutOfBounds(x, y) || !this.itemGrid) {
return null;
}
- return this.itemGrid[y][x];
+ var items = this.itemGrid[y][x],
+ item = null;
+
+ if(_.size(items) > 0) {
+ // If there are potions/burgers stacked with equipment items on the same tile, always get expendable items first.
+ _.each(items, function(i) {
+ if(Types.isExpendableItem(i.kind)) {
+ item = i;
+ };
+ });
+
+ // Else, get the first item of the stack
+ if(!item) {
+ item = items[_.keys(items)[0]];
+ }
+ }
+ return item;
},
/**
View
10 shared/js/gametypes.js
@@ -56,8 +56,6 @@ Types = {
PLATEARMOR: 24,
REDARMOR: 25,
GOLDENARMOR: 26,
- //PLATESHIELD: 27,
- //PLATECLOAK: 28,
// Objects
FLASK: 35,
@@ -178,8 +176,6 @@ Types.rankedArmors = [
Types.Entities.LEATHERARMOR,
Types.Entities.MAILARMOR,
Types.Entities.PLATEARMOR,
- //Types.Entities.PLATECLOAK,
- //Types.Entities.PLATESHIELD,
Types.Entities.REDARMOR,
Types.Entities.GOLDENARMOR
];
@@ -235,6 +231,12 @@ Types.isHealingItem = function(kind) {
|| kind === Types.Entities.BURGER;
};
+Types.isExpendableItem = function(kind) {
+ return Types.isHealingItem(kind)
+ || kind === Types.Entities.FIREPOTION
+ || kind === Types.Entities.CAKE;
+};
+
Types.getKindFromString = function(kind) {
if(kind in kinds) {
return kinds[kind][0];
Please sign in to comment.
Something went wrong with that request. Please try again.