Playtest
This commit is contained in:
+4
-3
@@ -1,6 +1,7 @@
|
||||
import type { GameObjectRegister } from "."
|
||||
import type { Effect } from "./Effect"
|
||||
import type { GameObjectNetcode } from "./GameObject"
|
||||
import type { Turn } from "./Turn"
|
||||
|
||||
enum CardRole {
|
||||
PERSONAL = "personal",
|
||||
@@ -8,7 +9,7 @@ enum CardRole {
|
||||
FIRE_GEM = "fire_gem"
|
||||
}
|
||||
|
||||
enum CardType {
|
||||
export enum CardType {
|
||||
HERO = "hero",
|
||||
HERO_ABILITY = "hero_ability",
|
||||
CURRENCY = "currency",
|
||||
@@ -48,10 +49,10 @@ export function create_card(input: CardNetcode, register: GameObjectRegister) {
|
||||
const card = new Proxy<any>(input, {
|
||||
get(target: CardNetcode, prop, reciever) {
|
||||
if (prop == "effects") {
|
||||
return target.effects.map((e) => register.effects[e])
|
||||
return target.effects.map((e) => register.effects.get(e))
|
||||
}
|
||||
if (prop == "health_as_champion") {
|
||||
return Object.values(register.turns).find(e => e.champions_health.has(card))?.champions_health.get(card)
|
||||
return Array.from(register.turns.values()).find(e => e.champions_health.has(card.uuid))?.champions_health.get(card.uuid)
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
|
||||
+33
-16
@@ -1,7 +1,7 @@
|
||||
import { GameObjectRegister } from "."
|
||||
import type { GameObjectNetcode } from "./GameObject"
|
||||
|
||||
enum CardEffects {
|
||||
export enum CardEffects {
|
||||
GOLD = "gold",
|
||||
DAMAGE = "damage",
|
||||
HEAL = "heal",
|
||||
@@ -18,14 +18,14 @@ enum CardEffects {
|
||||
PLAY_NEXT_CARD_BOUGHT = "play_next_card_bought"
|
||||
}
|
||||
|
||||
enum EffectTimes {
|
||||
export enum EffectTimes {
|
||||
PER_CHAMPION = "per_champion",
|
||||
PER_OTHER_CHAMPION = "per_other_champion",
|
||||
PER_OTHER_GUARD = "per_other_guard",
|
||||
PER_CARD_OF_SAME_FACTION = "per_card_of_same_faction"
|
||||
}
|
||||
|
||||
enum EffectType {
|
||||
export enum EffectType {
|
||||
CHAMPION_ACTION = "champion_action",
|
||||
SUICIDE = "suicide",
|
||||
FACTION_COMBO = "faction_combo"
|
||||
@@ -43,21 +43,38 @@ export interface EffectNetcode extends GameObjectNetcode {
|
||||
export type Effect = Omit<EffectNetcode, 'sub_effects' | 'mutex'> & {
|
||||
sub_effects: { [key: string]: Effect }
|
||||
mutex: { [key: string]: Effect }
|
||||
usable: boolean
|
||||
}
|
||||
|
||||
export function create_effect(input: EffectNetcode, register: GameObjectRegister) {
|
||||
return new Proxy<any>(input, {
|
||||
get(target, prop, reciever) {
|
||||
if (prop == "sub_effects") {
|
||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.sub_effects))
|
||||
const effect =
|
||||
new Proxy<any>(input, {
|
||||
get(target: EffectNetcode, prop, reciever) {
|
||||
if (prop == "sub_effects") {
|
||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.sub_effects))
|
||||
}
|
||||
if (prop == "mutex") {
|
||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.mutex))
|
||||
}
|
||||
if (prop == "usable") {
|
||||
if (target.effect_type == EffectType.FACTION_COMBO) {
|
||||
if (!register.self) { return false }
|
||||
// ugly bastard
|
||||
const card = register.self.board.find(c => c.effects.map(e => e.uuid).includes(effect.uuid))
|
||||
|
||||
if (!card) { return false }
|
||||
console.log(
|
||||
register.self.board.some(c => c !== card && c.faction === card.faction)
|
||||
)
|
||||
return register.self.board.some(c => c !== card && c.faction === card.faction)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
set(target, prop, val, receiver) {
|
||||
return Reflect.set(target, prop, val, receiver);
|
||||
}
|
||||
if (prop == "mutex") {
|
||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.mutex))
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
set(target, prop, val, receiver) {
|
||||
return Reflect.set(target, prop, val, receiver);
|
||||
}
|
||||
}) as Effect
|
||||
}) as Effect
|
||||
return effect
|
||||
}
|
||||
|
||||
+5
-4
@@ -20,15 +20,16 @@ export type Game = Omit<GameNetcode, 'market_stack' | 'market' | 'gem_stack' | '
|
||||
}
|
||||
export function create_game(input: GameNetcode, register: GameObjectRegister) {
|
||||
return new Proxy<any>(input, {
|
||||
get(target, prop, reciever) {
|
||||
get(target: GameNetcode, prop, reciever) {
|
||||
if (prop == "market_stack") {
|
||||
return input.market_stack.map(e => register.cards.get(e))
|
||||
return target.market_stack.map(e => register.cards.get(e))
|
||||
}
|
||||
if (prop == "market") {
|
||||
return input.market.map(e => register.cards.get(e))
|
||||
console.log(target)
|
||||
return target.market.map(e => register.cards.get(e))
|
||||
}
|
||||
if (prop == "gem_stack") {
|
||||
return input.gem_stack.map(e => register.cards.get(e))
|
||||
return target.gem_stack.map(e => register.cards.get(e))
|
||||
}
|
||||
if (prop == "current_turn") {
|
||||
return register.teams.get(input.current_turn)
|
||||
|
||||
+4
-5
@@ -16,13 +16,13 @@ export interface TurnNetcode extends GameObjectNetcode {
|
||||
export type Turn = Omit<TurnNetcode, 'cards_locked' | 'effects_availables' | 'champions_health'> & {
|
||||
cards_locked: { [key: string]: Card }
|
||||
effects_availables: Array<Effect>
|
||||
champions_health: Map<Card, number>
|
||||
champions_health: Map<string, number>
|
||||
}
|
||||
export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
||||
return new Proxy<any>(input, {
|
||||
get(target: TurnNetcode, prop, reciever) {
|
||||
if (prop == "card_locked") {
|
||||
return target.cards_locked.map(e => register.cards.get(e))
|
||||
if (prop == "cards_locked") {
|
||||
return Object.fromEntries(target.cards_locked.map(e => [e, register.cards.get(e)]))
|
||||
}
|
||||
if (prop == "effects_availables") {
|
||||
return target.effects_availables.map(e => register.effects.get(e))
|
||||
@@ -30,14 +30,13 @@ export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
||||
if (prop == "champions_health") {
|
||||
const healths = new Map()
|
||||
for (const c in target.champions_health) {
|
||||
healths.set(register.cards.get(c), target.champions_health[c])
|
||||
healths.set(register.cards.get(c)?.uuid, target.champions_health[c])
|
||||
}
|
||||
return healths
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
set(target, prop, val, receiver) {
|
||||
console.log(isReactive(target))
|
||||
return Reflect.set(target, prop, val, receiver);
|
||||
}
|
||||
}) as Turn
|
||||
|
||||
+20
-4
@@ -1,5 +1,5 @@
|
||||
import { type Card, create_card, type CardNetcode } from "./Card"
|
||||
import { type Effect, create_effect, type EffectNetcode } from "./Effect"
|
||||
import { type Effect, create_effect, type EffectNetcode, EffectType, CardEffects } from "./Effect"
|
||||
import { type Game, create_game, type GameNetcode } from "./Game"
|
||||
import type { GameObjectNetcode } from "./GameObject"
|
||||
import { type Player, create_player, type PlayerNetcode } from "./Player"
|
||||
@@ -176,16 +176,24 @@ export function lockCard(card: Card) {
|
||||
data_type: "lock_card",
|
||||
data: card.uuid
|
||||
}))
|
||||
card.effects.forEach(e => {
|
||||
if (e.effect_type !== EffectType.SUICIDE && e.usable && [CardEffects.DAMAGE, CardEffects.GOLD, CardEffects.HEAL].includes(e.effect)) {
|
||||
for (let i = 0; i < e.amount; i++) {
|
||||
useEffect(e)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function useEffect(effect: Effect, target?: Effect | Card | Player | Team) {
|
||||
console.log({ effect_id: effect.uuid, target: target?.uuid })
|
||||
socket.send(JSON.stringify({
|
||||
type: "action",
|
||||
data_type: "use_effect",
|
||||
data: { effect_id: effect.uuid, target: target?.uuid }
|
||||
}))
|
||||
}
|
||||
|
||||
export function discard(card: Card) {
|
||||
socket.send(JSON.stringify({
|
||||
type: "action",
|
||||
@@ -202,10 +210,18 @@ export function heal() {
|
||||
}))
|
||||
}
|
||||
|
||||
export function damage(target: Team) {
|
||||
export function damage_team(target: Team) {
|
||||
socket.send(JSON.stringify({
|
||||
type: "action",
|
||||
data_type: "damage",
|
||||
data_type: "damage_team",
|
||||
data: target.uuid
|
||||
}))
|
||||
}
|
||||
|
||||
export function damage_champion(target: Card) {
|
||||
socket.send(JSON.stringify({
|
||||
type: "action",
|
||||
data_type: "damage_champion",
|
||||
data: target.uuid
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user