Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
a4236002
Commit
a4236002
authored
May 27, 2023
by
timel
Committed by
Chunchi Che
May 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: cardstore attack logic
parent
cf7b89fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
src/service/duel/attack.ts
src/service/duel/attack.ts
+22
-10
src/stores/cardStore.ts
src/stores/cardStore.ts
+9
-2
No files found.
src/service/duel/attack.ts
View file @
a4236002
import
{
ygopro
}
from
"
@/api
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
fetchEsHintMeta
,
matStore
}
from
"
@/stores
"
;
import
{
cardStore
,
fetchEsHintMeta
,
matStore
}
from
"
@/stores
"
;
export
default
async
(
attack
:
ygopro
.
StocGameMessage
.
MsgAttack
)
=>
{
fetchEsHintMeta
({
...
...
@@ -8,10 +8,16 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
location
:
attack
.
attacker_location
,
});
const
attacker
=
matStore
.
in
(
attack
.
attacker_location
.
location
)
.
of
(
attack
.
attacker_location
.
controler
)
.
at
(
attack
.
attacker_location
.
sequence
);
// const attacker = matStore
// .in(attack.attacker_location.location)
// .of(attack.attacker_location.controler)
// .at(attack.attacker_location.sequence);
const
attacker
=
cardStore
.
at
(
attack
.
attacker_location
.
location
,
attack
.
attacker_location
.
controler
,
attack
.
attacker_location
.
sequence
);
if
(
attacker
)
{
if
(
attack
.
direct_attack
)
{
...
...
@@ -20,14 +26,20 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
await
sleep
(
500
);
attacker
.
directAttack
=
false
;
}
else
{
const
target
=
matStore
.
in
(
attack
.
target_location
.
location
)
.
of
(
attack
.
target_location
.
controler
)
.
at
(
attack
.
target_location
.
sequence
);
// const target = matStore
// .in(attack.target_location.location)
// .of(attack.target_location.controler)
// .at(attack.target_location.sequence);
const
target
=
cardStore
.
at
(
attack
.
target_location
.
location
,
attack
.
target_location
.
controler
,
attack
.
target_location
.
sequence
);
if
(
target
)
{
attacker
.
attackTarget
=
{
sequence
:
attack
.
target_location
.
sequence
,
sequence
:
attack
.
target_location
.
sequence
,
// FIXME: 确实会覆盖,代码这样没错吗
opponent
:
!
matStore
.
isMe
(
attack
.
target_location
.
controler
),
...
target
,
};
...
...
src/stores/cardStore.ts
View file @
a4236002
...
...
@@ -3,8 +3,7 @@ import { proxy } from "valtio";
import
type
{
Interactivity
}
from
"
./matStore/types
"
;
/**
* 场上某位置的状态,
* 以后会更名为 BlockState
* 场上某位置的状态
*/
export
interface
CardType
{
uuid
:
number
;
// 一张卡的唯一标识
...
...
@@ -27,6 +26,14 @@ export interface CardType {
counters
:
{
[
type
:
number
]:
number
};
// 指示器
reload
?:
boolean
;
// 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false
isToken
:
boolean
;
// 是否是token
// 新的字段(从matstore之中搬过来的)
focus
:
boolean
;
// 用于实现动画效果,当这个字段为true时,该张卡片会被放大并在屏幕中央展示
chaining
:
boolean
;
// 是否在连锁中
chainIndex
?:
number
/*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/
;
directAttack
:
boolean
;
// 是否正在直接攻击为玩家
attackTarget
?:
CardType
&
{
sequence
:
number
;
opponent
:
boolean
};
// 攻击目标。(嵌套结构可行么?)
}
class
CardStore
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment