Slime doesn't kill blobs; implement bribe; fix player size on level restart
This commit is contained in:
parent
0cd1ea342d
commit
b97aaa81a9
28
js/game.js
28
js/game.js
@ -223,10 +223,6 @@ const UNDO_BUFFER_SIZE = TICS_PER_SECOND * 30;
|
|||||||
export class Level {
|
export class Level {
|
||||||
constructor(stored_level, compat = {}) {
|
constructor(stored_level, compat = {}) {
|
||||||
this.stored_level = stored_level;
|
this.stored_level = stored_level;
|
||||||
this.width = stored_level.size_x;
|
|
||||||
this.height = stored_level.size_y;
|
|
||||||
this.size_x = stored_level.size_x;
|
|
||||||
this.size_y = stored_level.size_y;
|
|
||||||
this.restart(compat);
|
this.restart(compat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +236,11 @@ export class Level {
|
|||||||
// event loop!
|
// event loop!
|
||||||
this.state = 'playing';
|
this.state = 'playing';
|
||||||
|
|
||||||
|
this.width = this.stored_level.size_x;
|
||||||
|
this.height = this.stored_level.size_y;
|
||||||
|
this.size_x = this.stored_level.size_x;
|
||||||
|
this.size_y = this.stored_level.size_y;
|
||||||
|
|
||||||
this.cells = [];
|
this.cells = [];
|
||||||
this.player = null;
|
this.player = null;
|
||||||
this.actors = [];
|
this.actors = [];
|
||||||
@ -1749,19 +1750,34 @@ export class Level {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
take_tool_from_actor(actor, name) {
|
||||||
|
if (actor.toolbelt) {
|
||||||
|
let index = actor.toolbelt.indexOf(name);
|
||||||
|
if (index >= 0) {
|
||||||
|
actor.toolbelt.splice(index, 1);
|
||||||
|
this.pending_undo.push(() => actor.toolbelt.splice(index, 0, name));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
take_all_keys_from_actor(actor) {
|
take_all_keys_from_actor(actor) {
|
||||||
if (actor.keyring) {
|
if (actor.keyring && Object.values(actor.keyring).some(n => n > 0)) {
|
||||||
let keyring = actor.keyring;
|
let keyring = actor.keyring;
|
||||||
this.pending_undo.push(() => actor.keyring = keyring);
|
this.pending_undo.push(() => actor.keyring = keyring);
|
||||||
actor.keyring = {};
|
actor.keyring = {};
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
take_all_tools_from_actor(actor) {
|
take_all_tools_from_actor(actor) {
|
||||||
if (actor.toolbelt) {
|
if (actor.toolbelt && actor.toolbelt.length > 0) {
|
||||||
let toolbelt = actor.toolbelt;
|
let toolbelt = actor.toolbelt;
|
||||||
this.pending_undo.push(() => actor.toolbelt = toolbelt);
|
this.pending_undo.push(() => actor.toolbelt = toolbelt);
|
||||||
actor.toolbelt = [];
|
actor.toolbelt = [];
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -695,7 +695,7 @@ const TILE_TYPES = {
|
|||||||
if (other.type.name === 'dirt_block' || other.type.name === 'ice_block') {
|
if (other.type.name === 'dirt_block' || other.type.name === 'ice_block') {
|
||||||
level.transmute_tile(me, 'floor');
|
level.transmute_tile(me, 'floor');
|
||||||
}
|
}
|
||||||
else if (other.type.name === 'ghost') {
|
else if (other.type.name === 'ghost' || other.type.name === 'blob') {
|
||||||
// No effect
|
// No effect
|
||||||
}
|
}
|
||||||
else if (other.type.is_player) {
|
else if (other.type.is_player) {
|
||||||
@ -725,8 +725,14 @@ const TILE_TYPES = {
|
|||||||
draw_layer: DRAW_LAYERS.terrain,
|
draw_layer: DRAW_LAYERS.terrain,
|
||||||
blocks_collision: COLLISION.block_cc1 | COLLISION.monster_solid,
|
blocks_collision: COLLISION.block_cc1 | COLLISION.monster_solid,
|
||||||
on_arrive(me, level, other) {
|
on_arrive(me, level, other) {
|
||||||
level.sfx.play_once('thief', me.cell);
|
if (level.take_tool_from_actor(other, 'bribe')) {
|
||||||
level.take_all_tools_from_actor(other);
|
// TODO bribe sound
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level.take_all_tools_from_actor(other) && other === level.player) {
|
||||||
|
level.sfx.play_once('thief', me.cell);
|
||||||
|
}
|
||||||
if (other.type.is_player) {
|
if (other.type.is_player) {
|
||||||
level.adjust_bonus(0, 0.5);
|
level.adjust_bonus(0, 0.5);
|
||||||
}
|
}
|
||||||
@ -736,8 +742,14 @@ const TILE_TYPES = {
|
|||||||
draw_layer: DRAW_LAYERS.terrain,
|
draw_layer: DRAW_LAYERS.terrain,
|
||||||
blocks_collision: COLLISION.block_cc1 | COLLISION.monster_solid,
|
blocks_collision: COLLISION.block_cc1 | COLLISION.monster_solid,
|
||||||
on_arrive(me, level, other) {
|
on_arrive(me, level, other) {
|
||||||
level.sfx.play_once('thief', me.cell);
|
if (level.take_tool_from_actor(other, 'bribe')) {
|
||||||
level.take_all_keys_from_actor(other);
|
// TODO bribe sound
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level.take_all_keys_from_actor(other) && other === level.player) {
|
||||||
|
level.sfx.play_once('thief', me.cell);
|
||||||
|
}
|
||||||
if (other.type.is_player) {
|
if (other.type.is_player) {
|
||||||
level.adjust_bonus(0, 0.5);
|
level.adjust_bonus(0, 0.5);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user