diff options
-rw-r--r-- | play.html | 222 | ||||
-rw-r--r-- | play.js | 105 | ||||
-rw-r--r-- | rules.js | 220 |
3 files changed, 342 insertions, 205 deletions
@@ -24,47 +24,17 @@ main { box-shadow: inset 0 0 8px #0008; } -body.Observer #hand { - display: none; -} +#role_Red .role_name { background-color: hsl(359,100%,75%); } +#role_Blue .role_name { background-color: hsl(220,100%,80%); } +body.Observer #hand { display: none } .role_hand_size { float: right } -.court, #hand, #darkness { - font-family: "Albert Text"; - padding: 6px 10px; - text-align: right; - font-size: 20px; - color: #0004; -} - -#darkness { - position: absolute; - right: -2px; - bottom: -2px; - color: #444; - text-shadow: 0 0 4px white; -} - -#log { background-color: whitesmoke; } -#log .h1 { - margin: 6px 0; - padding: 2px 8px; - border-top: 1px solid black; - border-bottom: 1px solid black; - background-color: hsl(0,0%,85%); +.action { + cursor: pointer; } -#log .h1.x { background-color: hsl(0,0%,85%); } -#log .h1.gold { background-color: hsl(50,81%,79%); } -#log .h1.blue { background-color: hsl(201,80%,67%); } -#log .h1.white { background-color: hsl(0,0%,100%); } -#log .h1.red { background-color: hsl(0,90%,69%); } -#log .h1.purple { background-color: hsl(296,29%,65%); } -#log .h1.r{background-image:linear-gradient(90deg,transparent 180px,#000 180px,#000 181px, hsl(359,85%,60%) 181px); } -#log .h1.b{background-image:linear-gradient(90deg,transparent 180px,#000 180px,#000 181px, hsl(220,85%,60%) 181px); } -#role_Red .role_name { background-color: hsl(359,100%,75%); } -#role_Blue .role_name { background-color: hsl(220,100%,80%); } +/* BOARD */ #mapwrap { width: 825px; @@ -76,6 +46,14 @@ body.Observer #hand { height: calc(12px + 80px + 12px + 638px + 12px + 80px + 12px + 80px + 12px); } +#hand, .court { height: 80px; } + +#court1 { top: 12px } +#board { top: calc(12px + 80px + 12px) } +#court2 { top: calc(12px + 80px + 12px + 638px + 12px) } +#hand { top: calc(12px + 80px + 12px + 638px + 12px + 80px + 12px) } +#mapwrap { height: calc(12px + 80px + 12px + 638px + 12px + 80px + 12px + 80px) } + #board, #hand, .court { box-sizing: border-box; position: absolute; @@ -85,9 +63,6 @@ body.Observer #hand { box-shadow: 0 0 0 1px #222, 1px 1px 8px #0008; } -#hand, .court { - height: 80px; -} #board { height: 638px; @@ -95,33 +70,71 @@ body.Observer #hand { background-position: center; background-image: url(map75.jpg); border-color: #fff8 #2228 #2228 #fff8; + background-image: url(map75.jpg) } @media (min-resolution: 97dpi) { #board { background-image: url(map150.jpg) } } -#court1 { top: 12px } -#board { top: calc(12px + 80px + 12px) } -#court2 { top: calc(12px + 80px + 12px + 638px + 12px) } -#hand { top: calc(12px + 80px + 12px + 638px + 12px + 80px + 12px) } -#mapwrap { height: calc(12px + 80px + 12px + 638px + 12px + 80px + 12px + 80px) } - -#hand, .court { background-color: hsl(0,0%,55%) } +#hand { background-color: hsl(0,0%,50%) } .red.court { background-color: hsl(359,35%,55%) } .blue.court { background-color: hsl(220,35%,55%) } -#map div { +.court, #hand, #darkness_label { + font-family: "Albert Text"; + padding: 6px 10px; + text-align: right; + font-size: 20px; + color: #0006; +} + +#darkness_label { + position: absolute; + right: -2px; + bottom: -2px; + color: #444; + text-shadow: 0px -1px 10px white; +} + +#darkness_button { + position: absolute; + width: 56px; + height: 56px; + left: 10px; + bottom: 10px; +} + +#darkness_button.action { + background-color: #0002; + box-shadow: inset 0 0 16px 4px black, 0 0 0px 2px white, 0 0 8px 2px white; +} + +.space { position: absolute; + box-sizing: border-box; + border: 3px solid transparent; +} + +.space.oval { + border-radius: 50%; +} + +.space.action { + border: 3px solid white; + box-shadow: 0 0 4px white; +} + +/* PIECES */ + +.token, .tile { + position: absolute; + box-sizing: border-box; transition-property: top, left; transition-duration: 500ms; transition-timing-function: ease; } -.action { - cursor: pointer; -} - .token { width: 41px; height: 44px; @@ -145,8 +158,11 @@ body.Observer #hand { drop-shadow(0px -2px 0px yellow) } +.token.white { background-image: url(images/token_white.svg) } +.token.red { background-image: url(images/token_red.svg) } +.token.blue { background-image: url(images/token_blue.svg) } + .tile { - box-sizing: border-box; width: 56px; height: 56px; background-repeat: no-repeat; @@ -165,24 +181,6 @@ body.Observer #hand { box-shadow: 0 0 0 1px #222, 0 0 0 4px yellow; } -.space { - box-sizing: border-box; - border: 3px solid transparent; -} - -.space.oval { - border-radius: 50%; -} - -.space.action { - border: 3px solid white; - box-shadow: 0 0 4px white; -} - -.token.white { background-image: url(images/token_white.svg) } -.token.red { background-image: url(images/token_red.svg) } -.token.blue { background-image: url(images/token_blue.svg) } - .tile.gold { background-image: url(images/gold.png); background-color: hsl(50,81%,59%); } .tile.blue { background-image: url(images/blue.png); background-color: hsl(201,80%,47%); } .tile.white { background-image: url(images/white.png); background-color: hsl(0,0%,94%); } @@ -194,22 +192,67 @@ body.Observer #hand { .tile.white { border-color: #ddd #bbb #bbb #ddd } .tile.green { border-color: #fff3 #0003 #0003 #fff3 } +/* LOG */ + +#log { background-color: whitesmoke; } + +#log .h1 { + margin: 6px 0; + padding: 2px 8px; + border-top: 1px solid black; + border-bottom: 1px solid black; + background-color: hsl(0,0%,85%); +} + +#log .h1.x { background-color: hsl(0,0%,85%); } +#log .h1.r { background-color: hsl(359,85%,85%); } +#log .h1.b { background-color: hsl(220,85%,85%); } + +#log .t, #log .c, #log .o { + display: inline-block; + vertical-align: -2px; + width: 11px; + height: 11px; + border: 1px solid #222; +} + +#log .c { border-radius: 50%; } +#log .o { border-radius: 0 0 50% 50%; } + +#log .c.white { background-color: hsl(0,0%,94%) } +#log .c.red { background-color: hsl(359,85%,50%) } +#log .c.blue { background-color: hsl(220,85%,55%) } + +#log .t.gold { background-color: hsl(50,81%,59%); } +#log .t.blue { background-color: hsl(201,80%,47%); } +#log .t.white { background-color: hsl(0,0%,94%); } +#log .t.red { background-color: hsl(0,90%,49%); } +#log .t.green { background-color: hsl(125,21%,43%); } +#log .t.black { background-color: hsl(0,0%,35%); } + +#log .o.secrecy { background-color: hsl(0,0%,35%); } +#log .o.gold { background-color: hsl(50,81%,59%); } +#log .o.blue { background-color: hsl(201,80%,47%); } +#log .o.white { background-color: hsl(0,0%,94%); } +#log .o.red { background-color: hsl(0,90%,49%); } +#log .o.purple { background-color: hsl(296,29%,45%); } + </style> </head> <body> <header> <div id="toolbar"> - <div class="menu"> - <div class="menu_title"><img src="/images/cog.svg"></div> - <div class="menu_popup"> - <a class="menu_item" href="info/rules.html" target="_blank">Rules</a> - <div class="resign menu_separator"></div> - <div class="resign menu_item" onclick="confirm_resign()">Resign</div> + <div class="menu"> + <div class="menu_title"><img src="/images/cog.svg"></div> + <div class="menu_popup"> + <a class="menu_item" href="info/rules.html" target="_blank">Rules</a> + <div class="resign menu_separator"></div> + <div class="resign menu_item" onclick="confirm_resign()">Resign</div> + </div> </div> - </div> - <div class="icon_button" onclick="toggle_zoom()"><img src="/images/magnifying-glass.svg"></div> - <div class="icon_button" onclick="toggle_log()"><img src="/images/scroll-quill.svg"></div> + <div class="icon_button" onclick="toggle_zoom()"><img src="/images/magnifying-glass.svg"></div> + <div class="icon_button" onclick="toggle_log()"><img src="/images/scroll-quill.svg"></div> </div> <div id="prompt"></div> <div id="actions"></div> @@ -236,16 +279,17 @@ body.Observer #hand { </aside> <main> - -<div id="mapwrap" class="fit"> -<div id="map"> -<div id="court1" class="court">Rival Court</div> -<div id="board"><div id="darkness"></div></div> -<div id="court2" class="court">Court</div> -<div id="hand">Hand</div> -</div> -</div> - + <div id="mapwrap" class="fit"> + <div id="map"> + <div id="court1" class="red court">Rival Court</div> + <div id="board"> + <div id="darkness_button"></div> + <div id="darkness_label"></div> + </div> + <div id="court2" class="blue court">Court</div> + <div id="hand">Hand</div> + </div> + </div> </main> <footer id="status"></footer> @@ -2,11 +2,12 @@ /* global view, player, send_action, action_button, scroll_with_middle_mouse */ -const TILE_BLUE = 1 -const TILE_RED = 13 -const TILE_GOLD = 25 -const TILE_WHITE = 37 -const TILE_GREEN = 49 +const TILE_NONE = -1 +const TILE_GOLD = 0 +const TILE_BLUE = 12 +const TILE_WHITE = 24 +const TILE_RED = 36 +const TILE_GREEN = 48 const TILE_W = 56 const TILE_SPACE = TILE_W + 12 @@ -45,10 +46,10 @@ const LAYOUT_OVAL = [ [67,106,46,46], // off-board - [10,638-50], - [110,638-50], - [60,638-50], - [160,638-50], + [75,638-50], + [175,638-50], + [125,638-50], + [225,638-50], ] const LAYOUT_SQUARE = [ @@ -73,7 +74,8 @@ let ui = { board: document.getElementById("map"), court1: document.getElementById("court1"), court2: document.getElementById("court2"), - darkness: document.getElementById("darkness"), + darkness_label: document.getElementById("darkness_label"), + darkness_button: document.getElementById("darkness_button"), red_hand_size: document.getElementById("red_hand_size"), blue_hand_size: document.getElementById("blue_hand_size"), red_score: null, @@ -114,17 +116,12 @@ function create(t, p, ...c) { return e } -function create_token(p) { +function create_item(p) { let e = create("div", p) ui.board.appendChild(e) return e } -function create_tile(p) { - let e = create("div", p) - return e -} - let on_init_once = false function on_init() { @@ -150,25 +147,27 @@ function on_init() { ui.board.append(ui.square_spaces[i]) } - ui.red_score = create_token({ className: "token red", my_action: "score", my_id: 1 }) - ui.blue_score = create_token({ className: "token blue", my_action: "score", my_id: 2 }) + ui.red_score = create_item({ className: "token red", my_action: "score", my_id: 1 }) + ui.blue_score = create_item({ className: "token blue", my_action: "score", my_id: 2 }) + + ui.tokens[0] = create_item({ className: "token white", my_action: "token", my_id: 0 }) + ui.tokens[1] = create_item({ className: "token red", my_action: "token", my_id: 1 }) + ui.tokens[2] = create_item({ className: "token red", my_action: "token", my_id: 2 }) + ui.tokens[3] = create_item({ className: "token blue", my_action: "token", my_id: 3 }) + ui.tokens[4] = create_item({ className: "token blue", my_action: "token", my_id: 4 }) - ui.tokens[0] = create_token({ className: "token white", my_action: "token", my_id: 0 }) - ui.tokens[1] = create_token({ className: "token red", my_action: "token", my_id: 1 }) - ui.tokens[2] = create_token({ className: "token red", my_action: "token", my_id: 2 }) - ui.tokens[3] = create_token({ className: "token blue", my_action: "token", my_id: 3 }) - ui.tokens[4] = create_token({ className: "token blue", my_action: "token", my_id: 4 }) + ui.darkness_button.onclick = function () { send_action("darkness") } for (let i = TILE_BLUE; i < TILE_BLUE + 12; ++i) - ui.tiles[i] = create_tile({ className: "tile blue", my_action: "tile", my_id: i }) + ui.tiles[i] = create_item({ className: "tile blue", my_action: "tile", my_id: i }) for (let i = TILE_RED; i < TILE_RED + 12; ++i) - ui.tiles[i] = create_tile({ className: "tile red", my_action: "tile", my_id: i }) + ui.tiles[i] = create_item({ className: "tile red", my_action: "tile", my_id: i }) for (let i = TILE_GOLD; i < TILE_GOLD + 12; ++i) - ui.tiles[i] = create_tile({ className: "tile gold", my_action: "tile", my_id: i }) + ui.tiles[i] = create_item({ className: "tile gold", my_action: "tile", my_id: i }) for (let i = TILE_WHITE; i < TILE_WHITE + 12; ++i) - ui.tiles[i] = create_tile({ className: "tile white", my_action: "tile", my_id: i }) + ui.tiles[i] = create_item({ className: "tile white", my_action: "tile", my_id: i }) for (let i = TILE_GREEN; i < TILE_GREEN + 6; ++i) - ui.tiles[i] = create_tile({ className: "tile green", my_action: "tile", my_id: i }) + ui.tiles[i] = create_item({ className: "tile green", my_action: "tile", my_id: i }) } function show(elt) { @@ -186,9 +185,11 @@ function on_update() { ui.red_hand_size.textContent = view.red_hand + " in Hand" ui.blue_hand_size.textContent = view.blue_hand + " in Hand" - ui.darkness.textContent = view.darkness + " in Darkness" + ui.darkness_label.textContent = view.darkness + " in Darkness" - for (let i = 1; i <= 54; ++i) { + ui.darkness_button.classList.toggle("action", is_action("darkness")) + + for (let i = 0; i < 54; ++i) { if ((view.hand && view.hand.includes(i)) || view.red_court.includes(i) || view.blue_court.includes(i) || view.squares.includes(i)) show(ui.tiles[i]) else @@ -197,7 +198,7 @@ function on_update() { for (let i = 0; i < 6; ++i) { let k = view.squares[i] - if (k > 0) { + if (k !== TILE_NONE) { let x = LAYOUT_SQUARE[i][0] + TILE_DX + BOARD_X let y = LAYOUT_SQUARE[i][1] + TILE_DY + BOARD_Y ui.tiles[k].style.left = x + "px" @@ -279,11 +280,30 @@ function on_update() { for (let e of action_register) e.classList.toggle("action", is_action(e.my_action, e.my_id)) - action_button("darkness", "Darkness") + //action_button("darkness", "Darkness") action_button("done", "Done") action_button("undo", "Undo") } +const IMG_G = '<span class="t gold"></span>' +const IMG_B = '<span class="t blue"></span>' +const IMG_R = '<span class="t red"></span>' +const IMG_W = '<span class="t white"></span>' +const IMG_J = '<span class="t green"></span>' +const IMG_K = '<span class="t black"></span>' + +const IMG_OD = '<span class="c white"></span>' +const IMG_OS = '<span class="o secrecy"></span>' +const IMG_OG = '<span class="o gold"></span>' +const IMG_OB = '<span class="o blue"></span>' +const IMG_OR = '<span class="o red"></span>' +const IMG_OW = '<span class="o white"></span>' +const IMG_OP = '<span class="o purple"></span>' + +const IMG_CW = '<span class="c white"></span>' +const IMG_CR = '<span class="c red"></span>' +const IMG_CB = '<span class="c blue"></span>' + function on_log(text) { let p = document.createElement("div") if (text.match(/^\.r /)) { @@ -299,6 +319,17 @@ function on_log(text) { p.className = 'h1 x' } + text = text.replace(/\bG\b/g, IMG_G) + text = text.replace(/\bB\b/g, IMG_B) + text = text.replace(/\bR\b/g, IMG_R) + text = text.replace(/\bW\b/g, IMG_W) + text = text.replace(/\bJ\b/g, IMG_J) + text = text.replace(/\bK\b/g, IMG_K) + + text = text.replace(/\bCR\b/g, IMG_CR) + text = text.replace(/\bCB\b/g, IMG_CB) + text = text.replace(/\bCW\b/g, IMG_CW) + if (text.match(/^Dragon$/)) p.classList.add("dragon") if (text.match(/^Secrecy$/)) @@ -314,7 +345,15 @@ function on_log(text) { if (text.match(/^Collections$/)) p.classList.add("purple") - p.textContent = text + text = text.replace(/\bO0\b/g, IMG_OS) + text = text.replace(/\bO1\b/g, IMG_OG) + text = text.replace(/\bO2\b/g, IMG_OB) + text = text.replace(/\bO3\b/g, IMG_OW) + text = text.replace(/\bO4\b/g, IMG_OR) + text = text.replace(/\bO5\b/g, IMG_OP) + text = text.replace(/\bO6\b/g, IMG_OD) + + p.innerHTML = text return p } @@ -37,13 +37,13 @@ const S_OFF_BOARD_2 = 9 const S_OFF_BOARD_3 = 10 const S_OFF_BOARD_4 = 11 -const FIRST_TILE = 1 -const TILE_NONE = 0 -const TILE_BLUE = 1 -const TILE_RED = 13 -const TILE_GOLD = 25 -const TILE_WHITE = 37 -const TILE_GREEN = 49 +const TILE_NONE = -1 +const TILE_GOLD = 0 +const TILE_BLUE = 12 +const TILE_WHITE = 24 +const TILE_RED = 36 +const TILE_GREEN = 48 +const TILE_UNKNOWN = 60 const COUNT_NAME = [ "no", @@ -80,15 +80,35 @@ function space_name(s) { } } -function tile_name(tile) { - if (tile >= TILE_BLUE && tile < TILE_BLUE + 12) return "blue" - if (tile >= TILE_RED && tile < TILE_RED + 12) return "red" - if (tile >= TILE_GOLD && tile < TILE_GOLD + 12) return "gold" - if (tile >= TILE_WHITE && tile < TILE_WHITE + 12) return "white" - if (tile >= TILE_GREEN && tile < TILE_GREEN + 6) return "green" +const XTILE_NAME_UC = [ "Gold", "Blue", "White", "Red", "Green" ] +const XTILE_NAME_LC = [ "gold", "blue", "white", "red", "green" ] + +const TILE_NAME_UC = [ "Cloth", "Beasts", "Piety", "Tournaments", "Jewels" ] +const TILE_NAME_LC = [ "cloth", "beasts", "piety", "tournaments", "jewels" ] + +const TILE_NAME_CODE = [ "G", "B", "W", "R", "J", "K" ] +const TILE_NAME_CODE_X = [ [], [], [], [], [], [] ] + +for (let k = 0; k < 6; ++k) + for (let i = 0; i < 12; ++i) + TILE_NAME_CODE_X[k][i] = Array(i).fill(TILE_NAME_CODE[k]).join(" ") + +function tile_type(tile) { + return (tile / 12 | 0) * 12 +} + +function tile_name_count(tile, n) { + if (tile >= 0) + return TILE_NAME_CODE_X[tile / 12 | 0][n] return "None" } +function tile_name(tile) { + if (tile >= 0) + return TILE_NAME_CODE[tile / 12 | 0] + return "none" +} + function gen_action(action, argument) { if (!(action in view.actions)) view.actions[action] = [] @@ -111,6 +131,14 @@ function gen_action_square(space) { gen_action("square", space) } +function gen_action_score_red() { + gen_action("score", 1) +} + +function gen_action_score_blue() { + gen_action("score", 2) +} + function gen_action_score() { if (game.active === RED) gen_action("score", 1) @@ -193,9 +221,9 @@ exports.resign = function (state, player) { game = state if (game.state !== 'game_over') { if (player === RED) - goto_game_over(BLUE, "Red resigned.") + goto_game_over(BLUE, RED + " resigned.") if (player === BLUE) - goto_game_over(RED, "Blue resigned.") + goto_game_over(RED, BLUE + " resigned.") } return game } @@ -236,7 +264,7 @@ exports.setup = function (seed, scenario, options) { blue_hand: [], } - for (let i = FIRST_TILE; i < TILE_GREEN; ++i) + for (let i = 0; i < TILE_GREEN; ++i) game.darkness.push(i) shuffle(game.darkness) @@ -267,6 +295,12 @@ exports.setup = function (seed, scenario, options) { // === HANDS AND COURTS === +function rival_name() { + if (game.active === RED) + return BLUE + return RED +} + function rival_court() { if (game.active === RED) return game.blue_court @@ -314,34 +348,40 @@ function gift_tile_in_space(to) { // Gift associated tile to rival. if (to <= LAST_TILE_SPACE) { let tile = game.squares[to] - log("Gifted " + tile_name(tile) + ".") + log("Gift " + tile_name(tile)) game.squares[to] = TILE_NONE rival_court().push(tile) } } -function score_points(who, n) { +function score_points(who, n, reason = ".") { if (n > 0) { - if (n === 1) - log(who + " scored " + count_name(n) + " point.") - else - log(who + " scored " + count_name(n) + " points.") + log(who + " scored " + n + reason) if (who === RED) game.red_score += n - if (who === BLUE) + else game.blue_score += n } } function score_own_points(n) { - score_points(game.active, n) + if (n > 0) { + log("Score " + n) + if (game.active === RED) + game.red_score += n + else + game.blue_score += n + } } function score_rival_points(n) { - if (game.active === RED) - score_points(BLUE, n) - else - score_points(RED, n) + if (n > 0) { + log("Score " + n + " for rival") + if (game.active === RED) + game.blue_score += n + else + game.red_score += n + } } function count_tiles(list, type) { @@ -368,19 +408,19 @@ function gen_tile_in_list(type, list) { function log_reveal_tiles_into_court(type) { let n = count_tiles(own_hand(), type) if (n > 0) - log("Revealed " + count_name(n) + " " + tile_name(type) + ".") + log("Reveal " + tile_name_count(type, n)) } function log_remove_tiles_from_court(type) { let n = count_tiles(own_court(), type) if (n > 0) - log("Removed " + count_name(n) + " " + tile_name(type) + ".") + log("Remove " + tile_name_count(type, n)) } function log_remove_tiles_from_rival_court(type) { let n = count_tiles(rival_court(), type) if (n > 0) - log("Rival removed " + count_name(n) + " " + tile_name(type) + ".") + log("Remove " + tile_name_count(type, n) + " from rival") } function can_reveal_tiles_into_court(type) { @@ -468,11 +508,9 @@ states.move_token_to = { game.from = game.tokens[game.selected_token] if (game.active === RED) - log(".r " + space_name(to)) + log(".r O" + to + " " + space_name(to)) else - log(".b " + space_name(to)) - - //log("From " + space_name(game.from) + ".") + log(".b O" + to + " " + space_name(to)) // Move the token. game.tokens[game.selected_token] = to @@ -518,41 +556,29 @@ function end_turn() { // Return Dragon if needed. if (is_oval_space_empty(S_DRAGON_1) && game.tokens[TOKEN_DRAGON] !== S_DRAGON_2) { - game.state = "return_dragon_1" + game.state = "return_dragon" return } goto_refill_tiles() } -states.return_dragon_1 = { - inactive: "Dragon", +states.return_dragon = { + inactive: "End of Turn", prompt() { view.prompt = "End of Turn Move the Dragon back to its space." gen_action_token(TOKEN_DRAGON) }, token(_) { - game.state = "return_dragon_2" - }, -} - -states.return_dragon_2 = { - inactive: "End Turn", - prompt() { - view.prompt = "End Turn: Move the Dragon back to its space." - view.selected_token = TOKEN_DRAGON - gen_action_space(S_DRAGON_2) - }, - space(_) { - log("Returned Dragon.") + log("Return CW") game.tokens[TOKEN_DRAGON] = S_DRAGON_2 goto_refill_tiles() - } + }, } function must_refill_tiles() { for (let i = FIRST_SPACE; i <= LAST_TILE_SPACE; ++i) - if (is_oval_space_empty(i) && game.squares[i] === 0) + if (is_oval_space_empty(i) && game.squares[i] === TILE_NONE) return true return false } @@ -565,17 +591,17 @@ function goto_refill_tiles() { } states.refill_tiles = { - inactive: "End Turn", + inactive: "End of Turn", prompt() { - view.prompt = "End Turn: Place a new tile." + view.prompt = "End of Turn: Draw and place a new tile." for (let i = FIRST_SPACE; i <= LAST_TILE_SPACE; ++i) - if (is_oval_space_empty(i) && game.squares[i] === 0) + if (is_oval_space_empty(i) && game.squares[i] === TILE_NONE) gen_action_square(i) }, square(i) { clear_undo() let tile = game.darkness.pop() - log("Placed " + tile_name(tile) + " at " + space_name(i) + ".") + log("Place " + tile_name(tile) + " at O" + i) game.squares[i] = tile if (game.darkness.length === 0) return goto_end_of_the_contest() @@ -621,7 +647,7 @@ states.dragon_2 = { gen_action_space(i) }, space(to) { - log("Dragon to " + space_name(to) + ".") + log("Move CW to O" + to) game.tokens[TOKEN_DRAGON] = to gift_tile_in_space(to) end_turn() @@ -642,13 +668,13 @@ function gain_tiles_from_darkness_rival(n) { function gain_secrecy_tiles() { let n = Math.min(SECRECY_PER_ROW[own_score() / 8 | 0], game.darkness.length) - log("Gained " + count_name(n) + ".") + log("Gain " + tile_name_count(TILE_UNKNOWN, n)) gain_tiles_from_darkness(n) } function gain_secrecy_tiles_rival() { let n = Math.min(SECRECY_PER_ROW[rival_score() / 8 | 0], game.darkness.length) - log("Rival gained " + count_name(n) + ".") + log("Gain " + tile_name_count(TILE_UNKNOWN, n) + " to rival") gain_tiles_from_darkness_rival(n) } @@ -984,7 +1010,7 @@ states.tournaments_remove_rival = { states.tournaments_secrecy = { inactive: "Tournaments", prompt() { - view.prompt = "Tournaments: Gain tiles from the Darkness." + view.prompt = "Tournaments: Gain tiles from the Darkness for you and your rival." view.actions.darkness = 1 }, darkness() { @@ -1065,62 +1091,90 @@ function calc_gold_score(score, court) { function goto_end_of_the_contest() { log(".x End of the Contest") - game.state = "end_of_the_contest_jewels" + goto_end_of_the_contest_jewels_1() +} + +function goto_end_of_the_contest_jewels_1() { + if (calc_jewel_score(game.red_court)) + game.state = "end_of_the_contest_jewels_1" + else + goto_end_of_the_contest_jewels_2() +} + +function goto_end_of_the_contest_jewels_2() { + if (calc_jewel_score(game.blue_court)) + game.state = "end_of_the_contest_jewels_2" + else + goto_end_of_the_contest_gold_1() } -states.end_of_the_contest_jewels = { +function goto_end_of_the_contest_gold_1() { + if (calc_gold_score(game.red_score, game.red_court)) + game.state = "end_of_the_contest_gold_1" + else + goto_end_of_the_contest_gold_2() +} + +function goto_end_of_the_contest_gold_2() { + if (calc_gold_score(game.blue_score, game.blue_court)) + game.state = "end_of_the_contest_gold_2" + else + goto_victory() +} + +states.end_of_the_contest_jewels_1 = { inactive: "End of the Contest", prompt() { - prompt_score("End of the Contest", calc_jewel_score(own_court()), " for Jewels.") - gen_action_score() + prompt_score("End of the Contest", calc_jewel_score(game.red_court), " for Red's Jewels.") + gen_action_score_red() }, score() { - score_own_points(calc_jewel_score(own_court())) - game.state = "end_of_the_contest_jewels_rival" + score_points(RED, calc_jewel_score(game.red_court), " for Jewels.") + goto_end_of_the_contest_jewels_2() }, } -states.end_of_the_contest_jewels_rival = { +states.end_of_the_contest_jewels_2 = { inactive: "End of the Contest", prompt() { - prompt_score("End of the Contest", calc_jewel_score(rival_court()), " to your rival for Jewels.") - gen_action_score_rival() + prompt_score("End of the Contest", calc_jewel_score(game.blue_court), " for Blue's Jewels.") + gen_action_score_blue() }, score() { - score_rival_points(calc_jewel_score(rival_court())) - game.state = "end_of_the_contest_gold" + score_points(BLUE, calc_jewel_score(game.blue_court), " for Jewels.") + goto_end_of_the_contest_gold_1() }, } -states.end_of_the_contest_gold = { +states.end_of_the_contest_gold_1 = { inactive: "End of the Contest", prompt() { - prompt_score("End of the Contest", calc_gold_score(own_score(), own_court()), " for Gold.") - gen_action_score() + prompt_score("End of the Contest", calc_gold_score(game.red_score, game.red_court), " for Red's Gold.") + gen_action_score_red() }, score() { - score_own_points(calc_gold_score(own_score(), own_court())) - game.state = "end_of_the_contest_gold_rival" + score_points(RED, calc_gold_score(game.red_score, game.red_court), " for Gold.") + goto_end_of_the_contest_gold_2() }, } -states.end_of_the_contest_gold_rival = { +states.end_of_the_contest_gold_2 = { inactive: "End of the Contest", prompt() { - prompt_score("End of the Contest", calc_gold_score(rival_score(), rival_court()), " to your rival for Gold.") - gen_action_score_rival() + prompt_score("End of the Contest", calc_gold_score(game.blue_score, game.blue_court), " for Blue's Gold.") + gen_action_score_blue() }, score() { - score_rival_points(calc_gold_score(rival_score(), rival_court())) + score_points(BLUE, calc_gold_score(game.blue_score, game.blue_court), " for Gold.") goto_victory() }, } function victory_check(red, blue) { if (red > blue) - return goto_game_over(RED, "Red is the winner!") + return goto_game_over(RED, RED + " is the winner with " + game.red_score + " points!") if (blue > red) - return goto_game_over(BLUE, "Blue is the winner!") + return goto_game_over(BLUE, BLUE + " is the winner with " + game.blue_score + " points!") return true } |