Fix various missing dependencies and renamed variables

This commit is contained in:
Tissevert 2020-01-16 16:45:23 +01:00
parent 8bb722863a
commit 38ccd13634
4 changed files with 17 additions and 11 deletions

View file

@ -25,7 +25,7 @@ function HandCard(name) {
if(matching.length > 1) { if(matching.length > 1) {
State.select(card); State.select(card);
} else { } else {
State.play({play: card.name}); State.play({play: name});
} }
} }
} }

View file

@ -4,7 +4,9 @@ import * as RiverCard from GUI.Card.RiverCard;
import * as TurnedCard from GUI.Card.TurnedCard; import * as TurnedCard from GUI.Card.TurnedCard;
import * as Screen from GUI.Screen; import * as Screen from GUI.Screen;
import {animate, catchUp, delay, getQueue} from GUI.Screen.Game.Animation; import {animate, catchUp, delay, getQueue} from GUI.Screen.Game.Animation;
import {dom, init as initState, select, sets, state} from GUI.Screen.Game.State; import {
dom, init as initState, play, select, sets, state
} from GUI.Screen.Game.State;
import Hanafuda; import Hanafuda;
import I18n; import I18n;
import Messaging; import Messaging;
@ -75,7 +77,7 @@ function initMessageHandlers() {
} }
function handleGameMessage(o) { function handleGameMessage(o) {
if(o.state.public.turns == 0) { if(o.state.public.gameState.turns == 0 || state.game == null) {
if(o.logs.length > 0) { // but still some logs, from the previous round if(o.logs.length > 0) { // but still some logs, from the previous round
return Async.sequence(applyDiff(o), setGame(o)); // so play the diff, then set the new round return Async.sequence(applyDiff(o), setGame(o)); // so play the diff, then set the new round
} else { } else {
@ -121,7 +123,7 @@ function handleTurnedCard(o, f) {
setTurned(o.state.public.step.contents); setTurned(o.state.public.step.contents);
} else { } else {
if(state.step == "ToPlay" && o.state.public.playing == o.state.public.oyake) { if(state.step == "ToPlay" && o.state.public.playing == o.state.public.oyake) {
rest.className = ["card", "turn" + o.state.public.turns].join(' '); rest.className = ["card", "turn" + o.state.public.gameState.turns].join(' ');
} }
if(deck.lastChild.id != "rest") { if(deck.lastChild.id != "rest") {
deck.removeChild(deck.lastChild); deck.removeChild(deck.lastChild);
@ -217,7 +219,7 @@ function setCaptures(game) {
} }
function setCardSet(set, cardNames, constructor) { function setCardSet(set, cardNames, constructor) {
constructor = constructor || Card; constructor = constructor || Card.make;
set.card = {}; set.card = {};
Dom.clear(set.dom); Dom.clear(set.dom);
cardNames.forEach(function(cardName) { cardNames.forEach(function(cardName) {
@ -240,6 +242,6 @@ function setTheirCards(game) {
function setTurned(cardName) { function setTurned(cardName) {
state.turnedCard = TurnedCard.make(cardName); state.turnedCard = TurnedCard.make(cardName);
if(state.playing) { if(state.playing) {
select(turnedCard); select(state.turnedCard);
} }
} }

View file

@ -1,4 +1,6 @@
import * as Card from GUI.Card; import * as Card from GUI.Card;
import * as RiverCard from GUI.Card.RiverCard;
import * as TurnedCard from GUI.Card.TurnedCard;
import * as State from GUI.Screen.Game.State; import * as State from GUI.Screen.Game.State;
import * as Async from UnitJS.Async; import * as Async from UnitJS.Async;
import * as Dom from UnitJS.Dom; import * as Dom from UnitJS.Dom;
@ -30,7 +32,7 @@ function animate(movement) {
movingCards.push([State.sets[side].hand, dest, card]); movingCards.push([State.sets[side].hand, dest, card]);
} else { } else {
var cardSet = {}; var cardSet = {};
cardSet[card.name] = State.state.turnedCard || TurnedCard.make(card.name); cardSet[card.value.name] = State.state.turnedCard || TurnedCard.make(card.value.name);
State.state.turnedCard = null; State.state.turnedCard = null;
movingCards.push([{card: cardSet, dom: State.dom.deck}, dest, card]); movingCards.push([{card: cardSet, dom: State.dom.deck}, dest, card]);
} }
@ -66,7 +68,7 @@ function getQueue() {
function insertCard(toSet, card) { function insertCard(toSet, card) {
if(toSet.dom != undefined) { if(toSet.dom != undefined) {
toSet.card[card.name] = card; toSet.card[card.value.name] = card;
toSet.dom.appendChild(card.dom); toSet.dom.appendChild(card.dom);
} else { } else {
insertCard(toSet[card.value.family.class], card); insertCard(toSet[card.value.family.class], card);
@ -76,9 +78,9 @@ function insertCard(toSet, card) {
function moveCard(fromSet, toSet, card) { function moveCard(fromSet, toSet, card) {
var from, originalCard; var from, originalCard;
var slot = Dom.make('li', {class: ['card', 'slot']}); var slot = Dom.make('li', {class: ['card', 'slot']});
if (fromSet.card[card.name] != undefined) { if (fromSet.card[card.value.name] != undefined) {
originalCard = fromSet.card[card.name].dom; originalCard = fromSet.card[card.value.name].dom;
delete fromSet.card[card.name]; delete fromSet.card[card.value.name];
} else { } else {
originalCard = fromSet.dom.children[fromSet.dom.children.length - 1]; originalCard = fromSet.dom.children[fromSet.dom.children.length - 1];
} }

View file

@ -1,4 +1,6 @@
import Hanafuda;
import Messaging; import Messaging;
import * as Fun from UnitJS.Fun;
var dom = { var dom = {
deck: document.getElementById('deck'), deck: document.getElementById('deck'),