diff options
-rw-r--r-- | info/blocks.html | 126 | ||||
-rw-r--r-- | play.css | 10 | ||||
-rw-r--r-- | play.html | 11 | ||||
-rw-r--r-- | play.js | 201 | ||||
-rw-r--r-- | rules.js | 11 |
5 files changed, 172 insertions, 187 deletions
diff --git a/info/blocks.html b/info/blocks.html index 972b95c..a9eda36 100644 --- a/info/blocks.html +++ b/info/blocks.html @@ -25,69 +25,69 @@ div.frank { border: 3px solid darkkhaki; } div.saracen { border: 3px solid seagreen; } div.assassins { border: 3px solid rebeccapurple; } div.block:hover { transform: scale(2); } -.block_11{background-image:url(blocks/block_11.png)} -.block_12{background-image:url(blocks/block_12.png)} -.block_13{background-image:url(blocks/block_13.png)} -.block_14{background-image:url(blocks/block_14.png)} -.block_15{background-image:url(blocks/block_15.png)} -.block_16{background-image:url(blocks/block_16.png)} -.block_17{background-image:url(blocks/block_17.png)} -.block_21{background-image:url(blocks/block_21.png)} -.block_22{background-image:url(blocks/block_22.png)} -.block_23{background-image:url(blocks/block_23.png)} -.block_24{background-image:url(blocks/block_24.png)} -.block_25{background-image:url(blocks/block_25.png)} -.block_26{background-image:url(blocks/block_26.png)} -.block_27{background-image:url(blocks/block_27.png)} -.block_31{background-image:url(blocks/block_31.png)} -.block_32{background-image:url(blocks/block_32.png)} -.block_33{background-image:url(blocks/block_33.png)} -.block_34{background-image:url(blocks/block_34.png)} -.block_35{background-image:url(blocks/block_35.png)} -.block_36{background-image:url(blocks/block_36.png)} -.block_37{background-image:url(blocks/block_37.png)} -.block_41{background-image:url(blocks/block_41.png)} -.block_42{background-image:url(blocks/block_42.png)} -.block_43{background-image:url(blocks/block_43.png)} -.block_44{background-image:url(blocks/block_44.png)} -.block_45{background-image:url(blocks/block_45.png)} -.block_46{background-image:url(blocks/block_46.png)} -.block_47{background-image:url(blocks/block_47.png)} -.block_51{background-image:url(blocks/block_51.png)} -.block_52{background-image:url(blocks/block_52.png)} -.block_53{background-image:url(blocks/block_53.png)} -.block_54{background-image:url(blocks/block_54.png)} -.block_55{background-image:url(blocks/block_55.png)} -.block_56{background-image:url(blocks/block_56.png)} -.block_57{background-image:url(blocks/block_57.png)} -.block_61{background-image:url(blocks/block_61.png)} -.block_62{background-image:url(blocks/block_62.png)} -.block_63{background-image:url(blocks/block_63.png)} -.block_64{background-image:url(blocks/block_64.png)} -.block_65{background-image:url(blocks/block_65.png)} -.block_66{background-image:url(blocks/block_66.png)} -.block_67{background-image:url(blocks/block_67.png)} -.block_71{background-image:url(blocks/block_71.png)} -.block_72{background-image:url(blocks/block_72.png)} -.block_73{background-image:url(blocks/block_73.png)} -.block_74{background-image:url(blocks/block_74.png)} -.block_75{background-image:url(blocks/block_75.png)} -.block_76{background-image:url(blocks/block_76.png)} -.block_77{background-image:url(blocks/block_77.png)} -.block_81{background-image:url(blocks/block_81.png)} -.block_82{background-image:url(blocks/block_82.png)} -.block_83{background-image:url(blocks/block_83.png)} -.block_84{background-image:url(blocks/block_84.png)} -.block_85{background-image:url(blocks/block_85.png)} -.block_86{background-image:url(blocks/block_86.png)} -.block_87{background-image:url(blocks/block_87.png)} -.block_91{background-image:url(blocks/block_91.png)} -.block_92{background-image:url(blocks/block_92.png)} -.block_93{background-image:url(blocks/block_93.png)} -.block_94{background-image:url(blocks/block_94.png)} -.block_95{background-image:url(blocks/block_95.png)} -.block_96{background-image:url(blocks/block_96.png)} -.block_97{background-image:url(blocks/block_97.png)} +.block_11{background-image:url(../blocks/block_11.png)} +.block_12{background-image:url(../blocks/block_12.png)} +.block_13{background-image:url(../blocks/block_13.png)} +.block_14{background-image:url(../blocks/block_14.png)} +.block_15{background-image:url(../blocks/block_15.png)} +.block_16{background-image:url(../blocks/block_16.png)} +.block_17{background-image:url(../blocks/block_17.png)} +.block_21{background-image:url(../blocks/block_21.png)} +.block_22{background-image:url(../blocks/block_22.png)} +.block_23{background-image:url(../blocks/block_23.png)} +.block_24{background-image:url(../blocks/block_24.png)} +.block_25{background-image:url(../blocks/block_25.png)} +.block_26{background-image:url(../blocks/block_26.png)} +.block_27{background-image:url(../blocks/block_27.png)} +.block_31{background-image:url(../blocks/block_31.png)} +.block_32{background-image:url(../blocks/block_32.png)} +.block_33{background-image:url(../blocks/block_33.png)} +.block_34{background-image:url(../blocks/block_34.png)} +.block_35{background-image:url(../blocks/block_35.png)} +.block_36{background-image:url(../blocks/block_36.png)} +.block_37{background-image:url(../blocks/block_37.png)} +.block_41{background-image:url(../blocks/block_41.png)} +.block_42{background-image:url(../blocks/block_42.png)} +.block_43{background-image:url(../blocks/block_43.png)} +.block_44{background-image:url(../blocks/block_44.png)} +.block_45{background-image:url(../blocks/block_45.png)} +.block_46{background-image:url(../blocks/block_46.png)} +.block_47{background-image:url(../blocks/block_47.png)} +.block_51{background-image:url(../blocks/block_51.png)} +.block_52{background-image:url(../blocks/block_52.png)} +.block_53{background-image:url(../blocks/block_53.png)} +.block_54{background-image:url(../blocks/block_54.png)} +.block_55{background-image:url(../blocks/block_55.png)} +.block_56{background-image:url(../blocks/block_56.png)} +.block_57{background-image:url(../blocks/block_57.png)} +.block_61{background-image:url(../blocks/block_61.png)} +.block_62{background-image:url(../blocks/block_62.png)} +.block_63{background-image:url(../blocks/block_63.png)} +.block_64{background-image:url(../blocks/block_64.png)} +.block_65{background-image:url(../blocks/block_65.png)} +.block_66{background-image:url(../blocks/block_66.png)} +.block_67{background-image:url(../blocks/block_67.png)} +.block_71{background-image:url(../blocks/block_71.png)} +.block_72{background-image:url(../blocks/block_72.png)} +.block_73{background-image:url(../blocks/block_73.png)} +.block_74{background-image:url(../blocks/block_74.png)} +.block_75{background-image:url(../blocks/block_75.png)} +.block_76{background-image:url(../blocks/block_76.png)} +.block_77{background-image:url(../blocks/block_77.png)} +.block_81{background-image:url(../blocks/block_81.png)} +.block_82{background-image:url(../blocks/block_82.png)} +.block_83{background-image:url(../blocks/block_83.png)} +.block_84{background-image:url(../blocks/block_84.png)} +.block_85{background-image:url(../blocks/block_85.png)} +.block_86{background-image:url(../blocks/block_86.png)} +.block_87{background-image:url(../blocks/block_87.png)} +.block_91{background-image:url(../blocks/block_91.png)} +.block_92{background-image:url(../blocks/block_92.png)} +.block_93{background-image:url(../blocks/block_93.png)} +.block_94{background-image:url(../blocks/block_94.png)} +.block_95{background-image:url(../blocks/block_95.png)} +.block_96{background-image:url(../blocks/block_96.png)} +.block_97{background-image:url(../blocks/block_97.png)} </style> <body> <h1> @@ -3,8 +3,8 @@ aside { background-color: silver; } header { background-color: gainsboro; } body.Franks header.your_turn { background-color: #f7de46; /* 50% mix of khaki and gold */ } body.Saracens header.your_turn { background-color: lightgreen; } -.one .role_name { background-color: khaki; } -.two .role_name { background-color: darkseagreen; } +#role_Franks .role_name { background-color: khaki; } +#role_Saracens .role_name { background-color: darkseagreen; } #turn_info { background-color: gainsboro; } #log { background-color: whitesmoke; } @@ -277,9 +277,9 @@ body.shift .block.known:hover { #FF, #FC, #FR, #EF, #EC, #ER { margin: 0px auto; padding: 5px; } #EC { margin-bottom: 10px; } #FC { margin-bottom: 5px; } -#EC .battle_menu_list { min-height: 0; } -#ER .battle_menu_list { min-height: 0; } -#FR .battle_menu_list { min-height: 0; } +body:not(.replay) #EC .battle_menu_list { min-height: 0; } +body:not(.replay) #ER .battle_menu_list { min-height: 0; } +body:not(.replay) #FR .battle_menu_list { min-height: 0; } #FC, #EC { background-size: cover; @@ -6,11 +6,10 @@ <title>CRUSADER REX</title> <link rel="icon" href="Cross_of_the_Knights_Templar.svg"> <link rel="stylesheet" href="/fonts/fonts.css"> -<link rel="stylesheet" href="/common/grid.css"> -<link rel="stylesheet" href="/common/battle_abc.css"> +<link rel="stylesheet" href="/common/play.css"> +<link rel="stylesheet" href="/common/columbia.css"> <link rel="stylesheet" href="play.css"> -<script defer src="/socket.io/socket.io.min.js"></script> -<script defer src="/common/client.js"></script> +<script defer src="/common/play.js"></script> <script defer src="data.js"></script> <script defer src="play.js"></script> </head> @@ -55,7 +54,7 @@ <aside> <div id="roles"> - <div class="role one"> + <div class="role" id="role_Franks"> <div class="role_name"> Franks <div class="role_vp" id="frank_vp">VP</div> @@ -63,7 +62,7 @@ </div> <div class="role_info"><div class="show card card_back" id="frank_card"></div></div> </div> - <div class="role two"> + <div class="role" id="role_Saracens"> <div class="role_name"> Saracens <div class="role_vp" id="saracen_vp">VP</div> @@ -110,7 +110,7 @@ function block_owner(who) { return BLOCKS[who].owner; } function on_focus_map_block(evt) { let info = BLOCKS[evt.target.block]; - let where = game.location[evt.target.block]; + let where = view.location[evt.target.block]; if ((info.owner === player || info.owner === ASSASSINS) && where !== S_POOL && where !== F_POOL) { let text = info.name + " "; if (info.move) @@ -128,7 +128,7 @@ function on_blur_map_block(evt) { function on_click_map_block(evt) { let b = evt.target.block; - if (!game.battle) + if (!view.battle) send_action('block', b); } @@ -145,15 +145,15 @@ function on_focus_battle_block(evt) { msg = block_name(b); } - if (game.actions && game.actions.fire && game.actions.fire.includes(b)) + if (view.actions && view.actions.fire && view.actions.fire.includes(b)) msg = "Fire with " + msg; - else if (game.actions && game.actions.storm && game.actions.storm.includes(b)) + else if (view.actions && view.actions.storm && view.actions.storm.includes(b)) msg = "Storm with " + msg; - else if (game.actions && game.actions.sally && game.actions.sally.includes(b)) + else if (view.actions && view.actions.sally && view.actions.sally.includes(b)) msg = "Sally with " + msg; - else if (game.actions && game.actions.withdraw && game.actions.withdraw.includes(b)) + else if (view.actions && view.actions.withdraw && view.actions.withdraw.includes(b)) msg = "Withdraw with " + msg; - else if (game.actions && game.actions.hit && game.actions.hit.includes(b)) + else if (view.actions && view.actions.hit && view.actions.hit.includes(b)) msg = "Take hit on " + msg; document.getElementById("status").textContent = msg; @@ -174,7 +174,7 @@ function on_focus_fire(evt) { } function on_focus_retreat(evt) { - if (game.battle.storming.includes(evt.target.block)) + if (view.battle.storming.includes(evt.target.block)) document.getElementById("status").textContent = "Withdraw with " + block_name(evt.target.block); else @@ -469,22 +469,12 @@ function hide_block(element) { ui.offmap_element.appendChild(element); } -function show_block(element) { - if (element.parentElement !== ui.blocks_element) - ui.blocks_element.appendChild(element); -} - -function hide_block(element) { - if (element.parentElement !== ui.offmap_element) - ui.offmap_element.appendChild(element); -} - function is_known_block(info, who) { - if (game_over) + if (view.game_over) return true; - if (info.owner === player || info.owner === ASSASSINS || who === game.assassinate) + if (info.owner === player || info.owner === ASSASSINS || who === view.assassinate) return true; - let town = game.location[who]; + let town = view.location[who]; if (town === DEAD) return true; return false; @@ -493,47 +483,47 @@ function is_known_block(info, who) { function update_map() { let layout = {}; - document.getElementById("frank_vp").textContent = game.f_vp + " VP"; - document.getElementById("saracen_vp").textContent = game.s_vp + " VP"; - document.getElementById("timeline").className = "year_" + game.year; - if (game.turn < 1) + document.getElementById("frank_vp").textContent = view.f_vp + " VP"; + document.getElementById("saracen_vp").textContent = view.s_vp + " VP"; + document.getElementById("timeline").className = "year_" + view.year; + if (view.turn < 1) document.getElementById("turn_info").textContent = - "Year " + game.year; - else if (game.turn < 6) + "Year " + view.year; + else if (view.turn < 6) document.getElementById("turn_info").textContent = - "Turn " + game.turn + " of Year " + game.year; + "Turn " + view.turn + " of Year " + view.year; else document.getElementById("turn_info").textContent = - "Winter Turn of Year " + game.year; + "Winter Turn of Year " + view.year; for (let town in TOWNS) layout[town] = { north: [], south: [] }; - for (let b in game.location) { + for (let b in view.location) { let info = BLOCKS[b]; let element = ui.blocks[b]; - let town = game.location[b]; + let town = view.location[b]; if (town in TOWNS) { - let moved = game.moved[b] ? " moved" : ""; + let moved = view.moved[b] ? " moved" : ""; if (town === DEAD) moved = " moved"; if (is_known_block(info, b)) { let image = " block_" + info.image; - let steps = " r" + (info.steps - game.steps[b]); + let steps = " r" + (info.steps - view.steps[b]); let known = " known"; - if ((town === S_POOL || town === F_POOL) && b !== game.who && !game_over) + if ((town === S_POOL || town === F_POOL) && b !== view.who && !view.game_over) known = ""; element.classList = info.owner + known + " block" + image + steps + moved; } else { let besieging = ""; - if (game.sieges[town] === info.owner) { - if (game.winter_campaign === town) + if (view.sieges[town] === info.owner) { + if (view.winter_campaign === town) besieging = " winter_campaign"; else besieging = " besieging"; } let jihad = ""; - if (game.jihad === town && info.owner === game.p1) + if (view.jihad === town && info.owner === view.p1) jihad = " jihad"; element.classList = info.owner + " block" + moved + besieging + jihad; } @@ -549,10 +539,10 @@ function update_map() { } } - for (let b in game.location) { + for (let b in view.location) { let info = BLOCKS[b]; let element = ui.blocks[b]; - let town = game.location[b]; + let town = view.location[b]; if (town === DEAD) { if (info.owner === FRANKS) layout[F_POOL].north.unshift(element); @@ -570,20 +560,20 @@ function update_map() { ui.towns[where].classList.remove('muster'); } } - if (game.actions && game.actions.town) - for (let where of game.actions.town) + if (view.actions && view.actions.town) + for (let where of view.actions.town) ui.towns[where].classList.add('highlight'); - if (game.muster) - ui.towns[game.muster].classList.add('muster'); + if (view.muster) + ui.towns[view.muster].classList.add('muster'); - if (!game.battle) { - if (game.actions && game.actions.block) - for (let b of game.actions.block) + if (!view.battle) { + if (view.actions && view.actions.block) + for (let b of view.actions.block) ui.blocks[b].classList.add('highlight'); } - if (game.who && !game.battle) - ui.blocks[game.who].classList.add('selected'); - for (let b of game.castle) + if (view.who && !view.battle) + ui.blocks[view.who].classList.add('selected'); + for (let b of view.castle) ui.blocks[b].classList.add('castle'); } @@ -598,15 +588,15 @@ function update_card_display(element, card, prior_card) { } function update_cards() { - update_card_display(document.getElementById("frank_card"), game.f_card, game.prior_f_card); - update_card_display(document.getElementById("saracen_card"), game.s_card, game.prior_s_card); + update_card_display(document.getElementById("frank_card"), view.f_card, view.prior_f_card); + update_card_display(document.getElementById("saracen_card"), view.s_card, view.prior_s_card); for (let c = 1; c <= 27; ++c) { let element = ui.cards[c]; - if (game.hand.includes(c)) { + if (view.hand.includes(c)) { element.classList.add("show"); - if (game.actions && game.actions.play) { - if (game.actions.play.includes(c)) { + if (view.actions && view.actions.play) { + if (view.actions.play.includes(c)) { element.classList.add("enabled"); element.classList.remove("disabled"); } else { @@ -622,14 +612,12 @@ function update_cards() { } } - if (player === 'Observer') { - let n = game.hand.length; - for (let c = 1; c <= 6; ++c) - if (c <= n) - ui.card_backs[c].classList.add("show"); - else - ui.card_backs[c].classList.remove("show"); - } + let n = view.hand.length; + for (let c = 1; c <= 6; ++c) + if (c <= n && player === 'Observer') + ui.card_backs[c].classList.add("show"); + else + ui.card_backs[c].classList.remove("show"); } function compare_blocks(a, b) { @@ -664,47 +652,47 @@ function update_battle() { insert_battle_block(cell, ui.battle_menu[block], block); ui.battle_menu[block].className = "battle_menu"; - if (game.actions && game.actions.fire && game.actions.fire.includes(block)) + if (view.actions && view.actions.fire && view.actions.fire.includes(block)) ui.battle_menu[block].classList.add('fire'); - if (game.actions && game.actions.retreat && game.actions.retreat.includes(block)) + if (view.actions && view.actions.retreat && view.actions.retreat.includes(block)) ui.battle_menu[block].classList.add('retreat'); - if (game.actions && game.actions.harry && game.actions.harry.includes(block)) + if (view.actions && view.actions.harry && view.actions.harry.includes(block)) ui.battle_menu[block].classList.add('harry'); - if (game.actions && game.actions.charge && game.actions.charge.includes(block)) + if (view.actions && view.actions.charge && view.actions.charge.includes(block)) ui.battle_menu[block].classList.add('charge'); - if (game.actions && game.actions.withdraw && game.actions.withdraw.includes(block)) + if (view.actions && view.actions.withdraw && view.actions.withdraw.includes(block)) ui.battle_menu[block].classList.add('withdraw'); - if (game.actions && game.actions.storm && game.actions.storm.includes(block)) + if (view.actions && view.actions.storm && view.actions.storm.includes(block)) ui.battle_menu[block].classList.add('storm'); - if (game.actions && game.actions.sally && game.actions.sally.includes(block)) + if (view.actions && view.actions.sally && view.actions.sally.includes(block)) ui.battle_menu[block].classList.add('sally'); - if (game.actions && game.actions.charge && game.actions.charge.includes(block)) + if (view.actions && view.actions.charge && view.actions.charge.includes(block)) ui.battle_menu[block].classList.add('charge'); - if (game.actions && game.actions.treachery && game.actions.treachery.includes(block)) + if (view.actions && view.actions.treachery && view.actions.treachery.includes(block)) ui.battle_menu[block].classList.add('treachery'); - if (game.actions && game.actions.hit && game.actions.hit.includes(block)) + if (view.actions && view.actions.hit && view.actions.hit.includes(block)) ui.battle_menu[block].classList.add('hit'); let class_name = battle_block_class_name(BLOCKS[block]); - if (game.actions && game.actions.block && game.actions.block.includes(block)) + if (view.actions && view.actions.block && view.actions.block.includes(block)) class_name += " highlight"; - if (game.moved[block]) + if (view.moved[block]) class_name += " moved"; - if (block === game.who) + if (block === view.who) class_name += " selected"; - if (block === game.battle.halfhit) + if (block === view.battle.halfhit) class_name += " halfhit"; - if (game.jihad === game.battle.town && block_owner(block) === game.p1) + if (view.jihad === view.battle.town && block_owner(block) === view.p1) class_name += " jihad"; - if (game.battle.sallying.includes(block)) + if (view.battle.sallying.includes(block)) show = true; - if (game.battle.storming.includes(block)) + if (view.battle.storming.includes(block)) show = true; if (show || block_owner(block) === player) { class_name += " known"; ui.battle_block[block].className = class_name; - update_steps(block, game.steps[block], ui.battle_block[block], false); + update_steps(block, view.steps[block], ui.battle_block[block], false); } else { ui.battle_block[block].className = class_name; } @@ -720,23 +708,23 @@ function update_battle() { } if (player === FRANKS) { - fill_cell("ER", game.battle.SR, false); - fill_cell("EC", game.battle.SC, game.battle.show_castle); - fill_cell("EF", game.battle.SF, game.battle.show_field); - fill_cell("FF", game.battle.FF, game.battle.show_field); - fill_cell("FC", game.battle.FC, game.battle.show_castle); - fill_cell("FR", game.battle.FR, false); - document.getElementById("FC").className = "c" + game.battle.FCS; - document.getElementById("EC").className = "c" + game.battle.SCS; + fill_cell("ER", view.battle.SR, false); + fill_cell("EC", view.battle.SC, view.battle.show_castle); + fill_cell("EF", view.battle.SF, view.battle.show_field); + fill_cell("FF", view.battle.FF, view.battle.show_field); + fill_cell("FC", view.battle.FC, view.battle.show_castle); + fill_cell("FR", view.battle.FR, false); + document.getElementById("FC").className = "c" + view.battle.FCS; + document.getElementById("EC").className = "c" + view.battle.SCS; } else { - fill_cell("ER", game.battle.FR, false); - fill_cell("EC", game.battle.FC, game.battle.show_castle); - fill_cell("EF", game.battle.FF, game.battle.show_field); - fill_cell("FF", game.battle.SF, game.battle.show_field); - fill_cell("FC", game.battle.SC, game.battle.show_castle); - fill_cell("FR", game.battle.SR, false); - document.getElementById("EC").className = "c" + game.battle.FCS; - document.getElementById("FC").className = "c" + game.battle.SCS; + fill_cell("ER", view.battle.FR, false); + fill_cell("EC", view.battle.FC, view.battle.show_castle); + fill_cell("EF", view.battle.FF, view.battle.show_field); + fill_cell("FF", view.battle.SF, view.battle.show_field); + fill_cell("FC", view.battle.SC, view.battle.show_castle); + fill_cell("FR", view.battle.SR, false); + document.getElementById("EC").className = "c" + view.battle.FCS; + document.getElementById("FC").className = "c" + view.battle.SCS; } } @@ -747,12 +735,12 @@ function start_flash() { if (flash_timer) return; flash_timer = setInterval(function () { - if (!game.flash_next) { - element.textContent = game.battle ? game.battle.flash : ""; + if (!view.flash_next) { + element.textContent = view.battle ? view.battle.flash : ""; clearInterval(flash_timer); flash_timer = 0; } else { - element.textContent = tick ? game.battle.flash : game.flash_next; + element.textContent = tick ? view.battle.flash : view.flash_next; tick = !tick; } }, 1000); @@ -774,16 +762,16 @@ function on_update() { action_button("next", "Next"); action_button("undo", "Undo"); - document.getElementById("frank_vp").textContent = game.f_vp; - document.getElementById("saracen_vp").textContent = game.s_vp; + document.getElementById("frank_vp").textContent = view.f_vp; + document.getElementById("saracen_vp").textContent = view.s_vp; update_cards(); update_map(); - if (game.battle) { - document.getElementById("battle_header").textContent = game.battle.title; - document.getElementById("battle_message").textContent = game.battle.flash; - if (game.flash_next) + if (view.battle) { + document.getElementById("battle_header").textContent = view.battle.title; + document.getElementById("battle_message").textContent = view.battle.flash; + if (view.flash_next) start_flash(); document.getElementById("battle").classList.add("show"); update_battle(); @@ -796,6 +784,3 @@ build_map(); drag_element_with_mouse("#battle", "#battle_header"); scroll_with_middle_mouse("main", 3); -init_map_zoom(); -init_shift_zoom(); -init_client(["Franks", "Saracens"]); @@ -165,7 +165,7 @@ function clear_undo() { function push_undo() { game.undo.push(JSON.stringify(game, (k,v) => { - if (k === 'undo') return undefined; + if (k === 'undo') return 0; if (k === 'log') return v.length; return v; })); @@ -174,7 +174,7 @@ function push_undo() { function pop_undo() { let undo = game.undo; let save_log = game.log; - Object.assign(game, JSON.parse(undo.pop())); + game = JSON.parse(undo.pop()); game.undo = undo; save_log.length = game.log; game.log = save_log; @@ -3737,7 +3737,7 @@ exports.action = function (state, current, action, arg) { S[action](arg, current); else throw new Error("Invalid action: " + action); - return state; + return game; } exports.resign = function (state, current) { @@ -3750,7 +3750,7 @@ exports.resign = function (state, current) { game.victory = current + " resigned."; game.result = enemy(current); } - return state; + return game; } function make_siege_view() { @@ -3768,6 +3768,8 @@ function observer_hand() { return hand; } +exports.is_checkpoint = (a, b) => a.turn !== b.turn; + exports.view = function(state, current) { game = state; @@ -3786,7 +3788,6 @@ exports.view = function(state, current) { location: game.location, castle: game.castle, steps: game.steps, - reserves: game.reserves1.concat(game.reserves2), moved: game.moved, sieges: make_siege_view(), battle: null, |