From 0100f1e12ce38b6863cf82b0ebfe15bc2c5b91eb Mon Sep 17 00:00:00 2001 From: Timothy Stiles Date: Sat, 6 Feb 2021 16:07:40 +1100 Subject: [PATCH] spaceify --- js/format-c2g.js | 26 +++--- js/game.js | 40 ++++----- js/main-editor.js | 20 ++--- js/main.js | 4 +- js/tileset.js | 4 +- js/tiletypes.js | 220 +++++++++++++++++++++++----------------------- 6 files changed, 157 insertions(+), 157 deletions(-) diff --git a/js/format-c2g.js b/js/format-c2g.js index 28951f3..bd99b65 100644 --- a/js/format-c2g.js +++ b/js/format-c2g.js @@ -799,67 +799,67 @@ const TILE_ENCODING = { extra_args: [arg_direction], is_extension: true, }, - 0xe2: { + 0xe2: { name: 'skeleton_key', has_next: true, is_extension: true, }, - 0xe2: { + 0xe2: { name: 'gate_red', has_next: true, is_extension: true, }, - 0xe3: { + 0xe3: { name: 'gate_blue', has_next: true, is_extension: true, }, - 0xe4: { + 0xe4: { name: 'gate_yellow', has_next: true, is_extension: true, }, - 0xe5: { + 0xe5: { name: 'gate_green', has_next: true, is_extension: true, }, - 0xe6: { + 0xe6: { name: 'sand', has_next: true, is_extension: true, }, - 0xe7: { + 0xe7: { name: 'terraformer_n', has_next: true, is_extension: true, }, - 0xe8: { + 0xe8: { name: 'terraformer_e', has_next: true, is_extension: true, }, - 0xe9: { + 0xe9: { name: 'terraformer_s', has_next: true, is_extension: true, }, - 0xea: { + 0xea: { name: 'terraformer_w', has_next: true, is_extension: true, }, - 0xeb: { + 0xeb: { name: 'global_cycler', has_next: true, is_extension: true, }, - 0xec: { + 0xec: { name: 'halo', has_next: true, is_extension: true, }, - 0xed: { + 0xed: { name: 'fire_sticks', has_next: true, is_extension: true, diff --git a/js/game.js b/js/game.js index b24d233..3ce3559 100644 --- a/js/game.js +++ b/js/game.js @@ -2278,26 +2278,26 @@ export class Level extends LevelInterface { if (player === null) { player = this.player; } - - if (this.take_tool_from_actor(player, 'halo')) { - this.sfx.play_once('revive'); - if (reason === 'time') - { - this.pause_timer(); - } - else if (killer !== null) - { - if (killer.type.is_actor || killer.type.is_item) - { - this.remove_tile(killer); - } - else //presumably terrain - { - this.transmute_tile(killer, 'floor'); - } - } - return; - } + + if (this.take_tool_from_actor(player, 'halo')) { + this.sfx.play_once('revive'); + if (reason === 'time') + { + this.pause_timer(); + } + else if (killer !== null) + { + if (killer.type.is_actor || killer.type.is_item) + { + this.remove_tile(killer); + } + else //presumably terrain + { + this.transmute_tile(killer, 'floor'); + } + } + return; + } this._push_pending_undo(() => { this.fail_reason = null; diff --git a/js/main-editor.js b/js/main-editor.js index 1a1cf37..3370329 100644 --- a/js/main-editor.js +++ b/js/main-editor.js @@ -1600,8 +1600,8 @@ const EDITOR_PALETTE = [{ 'sand', 'terraformer_n', 'global_cycler', - 'halo', - 'fire_sticks', + 'halo', + 'fire_sticks', ], }]; @@ -2184,14 +2184,14 @@ const EDITOR_TILE_DESCRIPTIONS = { name: "Global Cycler", desc: "When activated, every terrain/item on the surrounding four tiles in the entire level becomes the terrain/item one clockwise. Adjacent tiles with a 'no sign' on them are ignored. Two of the same tile in a row mean that tile will not be transformed and will stay as-is. Tiles next to Global Cyclers are not transformed.", }, - halo: { - name: "Halo", - desc: "Protects the player from death once, destroying the would-be killer in the process.", - }, - fire_sticks: { - name: "Dormant Lava", - desc: "Acts like dirt. However, fireballs will enter it and turn it into Fire in the process.", - }, + halo: { + name: "Halo", + desc: "Protects the player from death once, destroying the would-be killer in the process.", + }, + fire_sticks: { + name: "Dormant Lava", + desc: "Acts like dirt. However, fireballs will enter it and turn it into Fire in the process.", + }, }; const SPECIAL_PALETTE_ENTRIES = { diff --git a/js/main.js b/js/main.js index 51b8044..3d1a2c9 100644 --- a/js/main.js +++ b/js/main.js @@ -311,8 +311,8 @@ class SFXPlayer { timeup: 'sfx/timeup.ogg', // https://jummbus.bitbucket.io/#j2N03winn200s0k0l00e00t2wm9a3g00j07i0r1O_U00o32T0v0EL0OD0Ou00q1d1f5y1z1C2w1c2h0T0v0pL0OD0Ou00q0d1f2y1z2C0w2c3h0b4gp1xFyW4xo31pe0MaCHCbwLbM5cFDgapBOyY0 win: 'sfx/win.ogg', - //from Ableton Retro Synths - 'revive': 'sfx/revive.ogg', + //from Ableton Retro Synths + 'revive': 'sfx/revive.ogg', }; for (let [name, path] of Object.entries(this.sound_sources)) { diff --git a/js/tileset.js b/js/tileset.js index 30c4644..7c98388 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -1036,8 +1036,8 @@ export const LL_TILESET_LAYOUT = Object.assign({}, CC2_TILESET_LAYOUT, { terraformer_s: [2, 43], terraformer_w: [3, 43], global_cycler: [4, 43], - halo: [5, 43], - fire_sticks: [6, 43], + halo: [5, 43], + fire_sticks: [6, 43], }); diff --git a/js/tiletypes.js b/js/tiletypes.js index d541a01..ce56904 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -681,7 +681,7 @@ const TILE_TYPES = { blocks_collision: COLLISION.block_cc1 | COLLISION.block_cc2, speed_factor: 0.5, }, - fire_sticks: { + fire_sticks: { layer: LAYERS.terrain, blocks_collision: COLLISION.block_cc1 | (COLLISION.monster_solid & ~COLLISION.rover & ~COLLISION.fireball), blocks(me, level, other) { @@ -692,14 +692,14 @@ const TILE_TYPES = { // Bizarre interaction if (other.type.name === 'ghost' && ! other.has_item('hiking_boots')) return; - if (other.type.name === 'fireball') - { - level.transmute_tile(me, 'fire'); - } - else - { - level.transmute_tile(me, 'floor'); - } + if (other.type.name === 'fireball') + { + level.transmute_tile(me, 'fire'); + } + else + { + level.transmute_tile(me, 'floor'); + } if (other === level.player) { level.sfx.play_once('step-gravel', me.cell); } @@ -1652,108 +1652,108 @@ const TILE_TYPES = { me.type.activate(me, level); }, }, - global_cycler: { - layer: LAYERS.terrain, + global_cycler: { + layer: LAYERS.terrain, blocks_collision: COLLISION.real_player | COLLISION.block_cc1 | COLLISION.monster_solid, activate(me, level) { //learn about surrounding tiles - //some logic: we ignore tiles with a 'no sign' on them. for items, we ignore itemless tiles. if the same terrain/item is twice in a row, it stays the same. tiles next to global cycles aren't touched. - let cells = [level.cell( - (me.cell.x + 0 + level.width) % level.width, - (me.cell.y - 1 + level.height) % level.height), - level.cell( - (me.cell.x + 1 + level.width) % level.width, - (me.cell.y + 0 + level.height) % level.height), - level.cell( - (me.cell.x + 0 + level.width) % level.width, - (me.cell.y + 1 + level.height) % level.height), - level.cell( - (me.cell.x - 1 + level.width) % level.width, - (me.cell.y + 0 + level.height) % level.height)].filter(x => x.get_item_mod()?.type.name != 'no_sign'); - let terrains = cells.map(x => x.get_terrain().type.name); - let items = cells.map(x => x.get_item()?.type.name ?? null).filter(x => x != null); - - //globally cycle terrain - if (terrains[0] != terrains[1] - || terrains[1] != terrains[2] - || terrains[2] != terrains[3] - || terrains[3] != terrains[0]) - { - for (var i = 0; i < level.width; ++i) - { - for (var j = 0; j < level.height; ++j) - { - let target_safe = [level.cell( - (i + 0 + level.width) % level.width, - (j - 1 + level.height) % level.height), - level.cell( - (i + 1 + level.width) % level.width, - (j + 0 + level.height) % level.height), - level.cell( - (i + 0 + level.width) % level.width, - (j + 1 + level.height) % level.height), - level.cell( - (i- 1 + level.width) % level.width, - (j + 0 + level.height) % level.height)].filter(x => x.get_terrain().type.name == 'global_cycler'); - if (target_safe.length > 0) - { - continue; - } - let thing = level.cell(i, j).get_terrain(); - let things = terrains; - for (var k = 0; k < things.length; ++k) - { - if (thing.type.name == things[k] && thing.type.name != things[(k - 1 + things.length) % things.length]) - { - level.transmute_tile(thing, things[(k + 1) % things.length]); - break; - } - } - } - } - } - - //globally cycle items - //some logic: we skip over itemless spots and if two items in the row are a same, then that item stays the same - if (new Set(items).size > 1) - { - for (var i = 0; i < level.width; ++i) - { - for (var j = 0; j < level.height; ++j) - { - let target_safe = [level.cell( - (i + 0 + level.width) % level.width, - (j - 1 + level.height) % level.height), - level.cell( - (i + 1 + level.width) % level.width, - (j + 0 + level.height) % level.height), - level.cell( - (i + 0 + level.width) % level.width, - (j + 1 + level.height) % level.height), - level.cell( - (i- 1 + level.width) % level.width, - (j + 0 + level.height) % level.height)].filter(x => x.get_terrain().type.name == 'global_cycler'); - if (target_safe.length > 0) - { - continue; - } - let thing = level.cell(i, j).get_item(); - let things = items; - if (thing == null) - { - continue; - } - for (var k = 0; k < things.length; ++k) - { - if (thing.type.name == things[k] && thing.type.name != things[(k - 1 + things.length) % things.length]) - { - level.transmute_tile(thing, things[(k + 1) % things.length]); - break; - } - } - } - } - } + //some logic: we ignore tiles with a 'no sign' on them. for items, we ignore itemless tiles. if the same terrain/item is twice in a row, it stays the same. tiles next to global cycles aren't touched. + let cells = [level.cell( + (me.cell.x + 0 + level.width) % level.width, + (me.cell.y - 1 + level.height) % level.height), + level.cell( + (me.cell.x + 1 + level.width) % level.width, + (me.cell.y + 0 + level.height) % level.height), + level.cell( + (me.cell.x + 0 + level.width) % level.width, + (me.cell.y + 1 + level.height) % level.height), + level.cell( + (me.cell.x - 1 + level.width) % level.width, + (me.cell.y + 0 + level.height) % level.height)].filter(x => x.get_item_mod()?.type.name != 'no_sign'); + let terrains = cells.map(x => x.get_terrain().type.name); + let items = cells.map(x => x.get_item()?.type.name ?? null).filter(x => x != null); + + //globally cycle terrain + if (terrains[0] != terrains[1] + || terrains[1] != terrains[2] + || terrains[2] != terrains[3] + || terrains[3] != terrains[0]) + { + for (var i = 0; i < level.width; ++i) + { + for (var j = 0; j < level.height; ++j) + { + let target_safe = [level.cell( + (i + 0 + level.width) % level.width, + (j - 1 + level.height) % level.height), + level.cell( + (i + 1 + level.width) % level.width, + (j + 0 + level.height) % level.height), + level.cell( + (i + 0 + level.width) % level.width, + (j + 1 + level.height) % level.height), + level.cell( + (i- 1 + level.width) % level.width, + (j + 0 + level.height) % level.height)].filter(x => x.get_terrain().type.name == 'global_cycler'); + if (target_safe.length > 0) + { + continue; + } + let thing = level.cell(i, j).get_terrain(); + let things = terrains; + for (var k = 0; k < things.length; ++k) + { + if (thing.type.name == things[k] && thing.type.name != things[(k - 1 + things.length) % things.length]) + { + level.transmute_tile(thing, things[(k + 1) % things.length]); + break; + } + } + } + } + } + + //globally cycle items + //some logic: we skip over itemless spots and if two items in the row are a same, then that item stays the same + if (new Set(items).size > 1) + { + for (var i = 0; i < level.width; ++i) + { + for (var j = 0; j < level.height; ++j) + { + let target_safe = [level.cell( + (i + 0 + level.width) % level.width, + (j - 1 + level.height) % level.height), + level.cell( + (i + 1 + level.width) % level.width, + (j + 0 + level.height) % level.height), + level.cell( + (i + 0 + level.width) % level.width, + (j + 1 + level.height) % level.height), + level.cell( + (i- 1 + level.width) % level.width, + (j + 0 + level.height) % level.height)].filter(x => x.get_terrain().type.name == 'global_cycler'); + if (target_safe.length > 0) + { + continue; + } + let thing = level.cell(i, j).get_item(); + let things = items; + if (thing == null) + { + continue; + } + for (var k = 0; k < things.length; ++k) + { + if (thing.type.name == things[k] && thing.type.name != things[(k - 1 + things.length) % things.length]) + { + level.transmute_tile(thing, things[(k + 1) % things.length]); + break; + } + } + } + } + } }, // Also activates on rising pulse or gray button on_power(me, level) { @@ -1762,7 +1762,7 @@ const TILE_TYPES = { on_gray_button(me, level) { me.type.activate(me, level); }, - }, + }, // Buttons button_blue: { layer: LAYERS.terrain, @@ -2758,7 +2758,7 @@ const TILE_TYPES = { is_tool: true, blocks_collision: COLLISION.block_cc1 | (COLLISION.monster_solid & ~COLLISION.rover), }, - halo: { + halo: { layer: LAYERS.item, is_item: true, is_tool: true,