Commit dd809f69 authored by chechunchi's avatar chechunchi

update small

parent 0e175d8e
Pipeline #19446 passed with stages
in 5 minutes and 31 seconds
......@@ -2,7 +2,6 @@ import { AsyncThunk, createAsyncThunk } from "@reduxjs/toolkit";
import { CardMeta } from "../../api/cards";
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { fetchCard } from "../../api/cards";
import { DuelState } from "./mod";
export interface DuelFieldState {
inner: CardState[];
......@@ -122,3 +121,35 @@ export function extendMeta<T extends DuelFieldState>(
}
}
}
export function extendPlaceInteractivity<T extends DuelFieldState>(
state: T | undefined,
controler: number,
sequence: number,
zone: ygopro.CardZone
) {
if (state) {
for (let item of state.inner) {
if (item.location.sequence == sequence) {
item.placeInteractivities = {
interactType: InteractType.PLACE_SELECTABLE,
response: {
controler,
zone,
sequence,
},
};
}
}
}
}
export function clearPlaceInteractivities<T extends DuelFieldState>(
state: T | undefined
) {
if (state) {
for (let item of state.inner) {
item.placeInteractivities = undefined;
}
}
}
......@@ -8,10 +8,11 @@ import { DuelState } from "./mod";
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { RootState } from "../../store";
import {
InteractType,
createAsyncMetaThunk,
DuelFieldState,
extendOccupant,
extendPlaceInteractivity,
clearPlaceInteractivities,
} from "./generic";
export interface MagicState extends DuelFieldState {}
......@@ -82,20 +83,7 @@ export const addMagicPlaceInteractivitiesImpl: CaseReducer<
const sequence = action.payload[1];
const magics = judgeSelf(controler, state) ? state.meMagics : state.opMagics;
if (magics) {
for (const magic of magics.inner) {
if (magic.location.sequence == sequence) {
magic.placeInteractivities = {
interactType: InteractType.PLACE_SELECTABLE,
response: {
controler,
zone: ygopro.CardZone.SZONE,
sequence,
},
};
}
}
}
extendPlaceInteractivity(magics, controler, sequence, ygopro.CardZone.SZONE);
};
export const clearMagicPlaceInteractivitiesImpl: CaseReducer<
......@@ -105,12 +93,7 @@ export const clearMagicPlaceInteractivitiesImpl: CaseReducer<
const player = action.payload;
const magics = judgeSelf(player, state) ? state.meMagics : state.opMagics;
if (magics) {
for (const magic of magics.inner) {
magic.placeInteractivities = undefined;
}
}
clearPlaceInteractivities(magics);
};
// 增加魔法陷阱
......
......@@ -9,9 +9,10 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { RootState } from "../../store";
import {
DuelFieldState,
InteractType,
createAsyncMetaThunk,
extendOccupant,
extendPlaceInteractivity,
clearPlaceInteractivities,
} from "./generic";
export interface MonsterState extends DuelFieldState {}
......@@ -84,20 +85,12 @@ export const addMonsterPlaceInteractivitiesImpl: CaseReducer<
const monsters = judgeSelf(controler, state)
? state.meMonsters
: state.opMonsters;
if (monsters) {
for (const monster of monsters.inner) {
if (monster.location.sequence == sequence) {
monster.placeInteractivities = {
interactType: InteractType.PLACE_SELECTABLE,
response: {
controler,
zone: ygopro.CardZone.MZONE,
sequence,
},
};
}
}
}
extendPlaceInteractivity(
monsters,
controler,
sequence,
ygopro.CardZone.MZONE
);
};
export const clearMonsterPlaceInteractivitiesImpl: CaseReducer<
......@@ -110,11 +103,7 @@ export const clearMonsterPlaceInteractivitiesImpl: CaseReducer<
? state.meMonsters
: state.opMonsters;
if (monsters) {
for (const monster of monsters.inner) {
monster.placeInteractivities = undefined;
}
}
clearPlaceInteractivities(monsters);
};
// 增加怪兽
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment