M5-M7: сцены, лобби, экран игры и цикл матча
Обе сцены собраны через Code Mode, не руками. - loader: поднимает модули, прогревает арт карт, уходит в lobby - lobby: обе UI-ветки в одной сцене (по ARCHITECTURE.md), матч — это смена видимого корня, а не загрузка сцены - GameScreen рисует текущее состояние и доводит узлы твинами, а не проигрывает поток событий: узел карты живёт вместе со своей картой, поэтому "шестёрка ушла из руки на стол" не требует отдельного случая - один тап = ход целиком; логика вынесена в core/rules/intent.ts и покрыта тестами, в том числе проверкой, что она никогда не предложит ход, который правила отвергнут - арт карт переехал в assets/resources: .pac — это инструкция упаковки на сборке, а не рантайм-ассет, и без ссылок на кадры в сборку не попадало ничего. Теперь все 37 спрайтов в одной текстуре 2048x2048 - клики кнопок подписываются в коде, а не через clickEvents сцены - строки интерфейса собраны в одном файле Сборка web-mobile проходит чисто, все ссылки в сцене проверены. Вживую не запускалось: браузер в этом окружении не поднимает главный цикл движка. Подробности — в docs/TECHNICAL.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { Card } from '../cards/Card';
|
||||
import { Action, Actions } from './Action';
|
||||
import { GameState, Phase, PlayerId } from './GameState';
|
||||
import { beats, currentActor, legalActions, unbeatenSlots } from './DurakRules';
|
||||
|
||||
/**
|
||||
* What tapping a card means for a player right now, or null if that card cannot
|
||||
* be played.
|
||||
*
|
||||
* This lives in the core rather than in the game screen so it can be tested
|
||||
* without the engine: it is the one piece of interface logic that can silently
|
||||
* turn a legal move into a rejected tap, and it is far too easy to get wrong by
|
||||
* eye. The screen just calls it and submits whatever comes back.
|
||||
*
|
||||
* One tap is the whole interaction. When defending, the attack to beat is worked
|
||||
* out here instead of being chosen separately — the serialised rules leave only
|
||||
* one unanswered attack at a time, and where several somehow exist the lowest
|
||||
* slot this card can beat is taken.
|
||||
*/
|
||||
export function intentFor(state: GameState, player: PlayerId, card: Card): Action | null {
|
||||
if (currentActor(state) !== player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.phase === Phase.Defence) {
|
||||
const slot = unbeatenSlots(state)
|
||||
.find((i) => beats(card, state.table[i].attack, state.trumpSuit));
|
||||
return slot === undefined ? null : Actions.defend(player, card, slot);
|
||||
}
|
||||
|
||||
const wanted = Actions.attack(player, card);
|
||||
const legal = legalActions(state, player)
|
||||
.some((a) => a.type === wanted.type && (a as { card?: Card }).card === card);
|
||||
return legal ? wanted : null;
|
||||
}
|
||||
Reference in New Issue
Block a user