-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFight_test.go
107 lines (96 loc) · 2.91 KB
/
Fight_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package GameFight
import (
"fmt"
"testing"
)
func TestFightCell_Fight(t *testing.T) {
fightCell := FightCell{
mAttackList: nil,
mDefenceList: nil,
mFightInfo: new(FightInfo),
mRoundInfo: new(FightRoundInfo),
mFightType: 0,
mPlusAtt: 0,
}
attackObjList := FightObjList{
mOwnerGuid: 1,
mObjectList: [6]*FightObject{},
}
attackerHeroList := [MaxMatrixCellCount]int{9}
fightCell.mAttackList = &attackObjList
defendObjList := FightObjList{
mOwnerGuid: 1,
mObjectList: [6]*FightObject{},
}
fightCell.mDefenceList = &defendObjList
defendHeroList := [MaxMatrixCellCount]int{10}
FillFightObjList(attackerHeroList, fightCell.GetAttackList())
FillFightObjList(defendHeroList, fightCell.GetDefenceList())
fightCell.InitAttackList()
fightCell.InitDefendList(0)
fightCell.Fight()
}
func FillFightObjList(heroList [MaxMatrixCellCount]int, pFightObjList *FightObjList) bool {
for i := 0; i < MaxMatrixCellCount; i++ {
fightObject := new(FightObject)
if FillFightObjByCfg(heroList[i], fightObject) {
pFightObjList.FillObject(i, fightObject)
}
}
return true
}
//heroId 英雄id
func FillFightObjByCfg(heroId int, fightObject *FightObject) bool {
pHeroRow, ok := G_HeroAttr[heroId]
if !ok {
panic("cfg error")
}
fightDBData := FightDBData{
Guid: X_GUID(heroId),
TableID: heroId,
Type: 0,
Quality: pHeroRow.InitQuality,
MatrixID: 0,
Profession: pHeroRow.Profession,
Level: pHeroRow.InitLevel,
HP: pHeroRow.InitHP,
Mp: pHeroRow.InitMP,
SkillCount: MaxSkillNum,
Skill: [2]int{pHeroRow.MagicSkillID1, pHeroRow.MagicSkillID2},
EquipSkillCount: 0,
EquipSkill: [6]int{},
PhysicAttack: pHeroRow.InitPhysicAttack,
MagicAttack: pHeroRow.InitMagicAttack,
PhysicDefence: pHeroRow.InitPhysicDefence,
MagicDefence: pHeroRow.InitMagicDefence,
MaxHP: pHeroRow.InitHP,
MaxMP: pHeroRow.InitMP,
Hit: pHeroRow.InitHit,
Dodge: pHeroRow.InitDodge,
Strike: pHeroRow.InitStrike,
StrikeHurt: pHeroRow.InitStrikeHurt,
Continuous: pHeroRow.InitContinuous,
ConAttHurt: pHeroRow.InitConAttHurt,
ConAttTimes: pHeroRow.InitConAttTimes,
BackAttack: pHeroRow.InitBackAttack,
BackAttHurt: pHeroRow.InitBackAttHurt,
AttackSpeed: pHeroRow.InitAttackSpeed,
PhysicHurtDecay: pHeroRow.InitPhysicHurtDecay,
MagicHurtDecay: pHeroRow.InitMagicHurtDecay,
Exp: 0,
GrowRate: 0,
BearPoint: 0,
Equip: [6]int{InvalidId, InvalidId, InvalidId, InvalidId, InvalidId, InvalidId},
Color: 1,
}
fightObject.InitFightDBData(fightDBData)
return true
}
func TestX_GUID_IsValid(t *testing.T) {
guid := X_GUID(2)
fmt.Println(guid.IsValid())
}
func TestFuncInArr(t *testing.T){
arr := [2]func(){func(){ fmt.Println(1)}, func(){ fmt.Println(2)}}
arr[1]()
}