Compare commits
3 Commits
43881fd988
...
5204615c28
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5204615c28 | ||
|
|
3c160ef695 | ||
|
|
c19ee7de03 |
@@ -1,36 +0,0 @@
|
||||
# Task 165: Effects 1438-1442
|
||||
|
||||
## 目标
|
||||
|
||||
- 补齐以下 5 个(或最后一组不足 5 个)当前判定未实现的 skill effect。
|
||||
- 实现位置优先放在 `logic/service/fight/effect/`。
|
||||
- 如 effect 需要展示说明,同步更新 `logic/service/fight/effect/effect_info_map.go`。
|
||||
- 完成后至少执行:`cd /workspace/logic && go test ./service/fight/effect`。
|
||||
|
||||
## Effect 列表
|
||||
|
||||
### Effect 1438
|
||||
- `argsNum`: `1`
|
||||
- `info`: `若对手处于能力下降状态,则{0}回合内令对手使用的属性技能无效`
|
||||
|
||||
### Effect 1439
|
||||
- `argsNum`: `1`
|
||||
- `info`: `对手处于能力下降状态造成的伤害提升{0}%`
|
||||
|
||||
### Effect 1440
|
||||
- `argsNum`: `1`
|
||||
- `info`: `免疫下{0}次自身受到的异常状态`
|
||||
|
||||
### Effect 1441
|
||||
- `argsNum`: `1`
|
||||
- `info`: `解除自身能力下降状态,解除成功则使对手随机{0}个技能PP值归零`
|
||||
|
||||
### Effect 1442
|
||||
- `argsNum`: `4`
|
||||
- `info`: `{0}回合内每回合{1}%闪避对手攻击,未触发则回合结束时{2}%令对手{3}`
|
||||
- `param`: `1,3,3`
|
||||
|
||||
## 备注
|
||||
|
||||
- 该清单按当前仓库静态注册结果生成;如果某个 effect 实际通过其他模块或运行时路径实现,需要先复核后再落代码。
|
||||
- 对 `201`、`445` 这类占位 effect,优先补核心逻辑或补充明确的不可实现说明。
|
||||
@@ -1,36 +0,0 @@
|
||||
# Task 166: Effects 1443-1447
|
||||
|
||||
## 目标
|
||||
|
||||
- 补齐以下 5 个(或最后一组不足 5 个)当前判定未实现的 skill effect。
|
||||
- 实现位置优先放在 `logic/service/fight/effect/`。
|
||||
- 如 effect 需要展示说明,同步更新 `logic/service/fight/effect/effect_info_map.go`。
|
||||
- 完成后至少执行:`cd /workspace/logic && go test ./service/fight/effect`。
|
||||
|
||||
## Effect 列表
|
||||
|
||||
### Effect 1443
|
||||
- `argsNum`: `2`
|
||||
- `info`: `连续使用时威力提升{0}%,最高提升{1}%`
|
||||
|
||||
### Effect 1444
|
||||
- `argsNum`: `0`
|
||||
- `info`: `威力根据自身体力变化,当前剩余体力越少则威力越大`
|
||||
|
||||
### Effect 1445
|
||||
- `argsNum`: `3`
|
||||
- `info`: `吸取对手能力提升状态,吸取成功则{0}回合内对手属性技能无效,若对手不处于能力提升状态则自身下{1}回合先制+{2}`
|
||||
|
||||
### Effect 1446
|
||||
- `argsNum`: `2`
|
||||
- `info`: `获得{0}点护罩,护罩消失时使对手全属性-{1}`
|
||||
|
||||
### Effect 1447
|
||||
- `argsNum`: `3`
|
||||
- `info`: `自身体力高于最大体力的1/{0}时{1}%令对手{2}`
|
||||
- `param`: `1,2,2`
|
||||
|
||||
## 备注
|
||||
|
||||
- 该清单按当前仓库静态注册结果生成;如果某个 effect 实际通过其他模块或运行时路径实现,需要先复核后再落代码。
|
||||
- 对 `201`、`445` 这类占位 effect,优先补核心逻辑或补充明确的不可实现说明。
|
||||
199
logic/controller/pet_bag.go
Normal file
199
logic/controller/pet_bag.go
Normal file
@@ -0,0 +1,199 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// SavePetBagOrder 保存当前主背包和备用背包顺序
|
||||
func (h Controller) SavePetBagOrder(
|
||||
data *pet.SavePetBagOrderInboundInfo,
|
||||
player *player.Player) (result *fight.NullOutboundInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
syncBackupPetList(player)
|
||||
|
||||
if len(data.PetList) > 6 || len(data.BackupPetList) > 6 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
totalPetCount := len(player.Info.PetList) + len(player.Info.BackupPetList)
|
||||
if len(data.PetList)+len(data.BackupPetList) != totalPetCount {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
petMap := buildPetInfoMap(player.Info.PetList, player.Info.BackupPetList)
|
||||
used := make(map[uint32]struct{}, totalPetCount)
|
||||
|
||||
battleList, ok := buildOrderedPetList(data.PetList, petMap, used)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
backupList, ok := buildOrderedPetList(data.BackupPetList, petMap, used)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
if len(used) != totalPetCount {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
player.Info.PetList = battleList
|
||||
player.Info.BackupPetList = backupList
|
||||
player.Service.Info.Save(*player.Info)
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
// PetRetrieveFromWarehouse 领回仓库精灵
|
||||
func (h Controller) PetRetrieveFromWarehouse(
|
||||
data *pet.PET_RETRIEVE, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if _, ok := findPetListSlot(player, data.CatchTime); ok {
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if petInfo == nil {
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
syncBackupPetList(player)
|
||||
changed := false
|
||||
if len(player.Info.PetList) < 6 {
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
changed = true
|
||||
} else if len(player.Info.BackupPetList) < 6 {
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
player.Service.Info.Save(*player.Info)
|
||||
}
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
// TogglePetBagWarehouse 精灵背包仓库切换
|
||||
func (h Controller) TogglePetBagWarehouse(
|
||||
data *pet.PetReleaseInboundInfo,
|
||||
player *player.Player) (result *pet.PetReleaseOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &pet.PetReleaseOutboundInfo{
|
||||
Flag: uint32(data.Flag),
|
||||
}
|
||||
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
syncBackupPetList(player)
|
||||
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
slot, ok := findPetListSlot(player, data.CatchTime)
|
||||
if !ok {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
if !slot.isValid() {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if !player.Service.Pet.Update(slot.info) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
slot.remove()
|
||||
if slot.kind == petListKindMain {
|
||||
player.Service.Info.Save(*player.Info)
|
||||
}
|
||||
|
||||
case 1:
|
||||
if len(player.Info.PetList) >= 6 && len(player.Info.BackupPetList) >= 6 {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if _, ok := findPetListSlot(player, data.CatchTime); ok {
|
||||
return result, 0
|
||||
}
|
||||
|
||||
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if petInfo == nil {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
if len(player.Info.PetList) < 6 {
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
} else {
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
|
||||
}
|
||||
result.PetInfo = petInfo.Data
|
||||
}
|
||||
|
||||
if len(player.Info.PetList) > 0 {
|
||||
result.FirstPetTime = player.Info.PetList[0].CatchTime
|
||||
}
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// TogglePetBagWarehouseLegacy 旧版精灵背包仓库切换
|
||||
func (h Controller) TogglePetBagWarehouseLegacy(
|
||||
data *pet.PetReleaseLegacyInboundInfo,
|
||||
player *player.Player) (result *pet.PetReleaseOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &pet.PetReleaseOutboundInfo{
|
||||
Flag: uint32(data.Flag),
|
||||
}
|
||||
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
index, currentPet, ok := player.FindPet(data.CatchTime)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
if index < 0 || index >= len(player.Info.PetList) {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if !player.Service.Pet.Update(*currentPet) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
player.Info.PetList = append(player.Info.PetList[:index], player.Info.PetList[index+1:]...)
|
||||
player.Info.BackupPetList = removePetByCatchTime(player.Info.BackupPetList, data.CatchTime)
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, *currentPet)
|
||||
|
||||
case 1:
|
||||
if len(player.Info.PetList) >= 6 {
|
||||
break
|
||||
}
|
||||
|
||||
if _, _, ok := player.FindPet(data.CatchTime); ok {
|
||||
player.Info.BackupPetList = removePetByCatchTime(player.Info.BackupPetList, data.CatchTime)
|
||||
break
|
||||
}
|
||||
|
||||
if index, backupPet, ok := findBackupPet(player, data.CatchTime); ok {
|
||||
if index < 0 || index >= len(player.Info.BackupPetList) {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
result.PetInfo = *backupPet
|
||||
player.Info.PetList = append(player.Info.PetList, *backupPet)
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList[:index], player.Info.BackupPetList[index+1:]...)
|
||||
break
|
||||
}
|
||||
|
||||
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if petInfo == nil {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
result.PetInfo = petInfo.Data
|
||||
}
|
||||
|
||||
if len(player.Info.PetList) > 0 {
|
||||
result.FirstPetTime = player.Info.PetList[0].CatchTime
|
||||
}
|
||||
|
||||
return result, 0
|
||||
}
|
||||
@@ -1,181 +1,28 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
func buildPetShortInfo(info model.PetInfo) pet.PetShortInfo {
|
||||
return pet.PetShortInfo{
|
||||
ID: info.ID,
|
||||
CatchTime: info.CatchTime,
|
||||
Level: info.Level,
|
||||
SkinID: info.SkinID,
|
||||
ShinyLen: info.ShinyLen,
|
||||
ShinyInfo: info.ShinyInfo,
|
||||
}
|
||||
}
|
||||
|
||||
func buildPetListOutboundInfo(petList []model.PetInfo) *pet.GetPetListOutboundInfo {
|
||||
result := &pet.GetPetListOutboundInfo{
|
||||
ShortInfoList: make([]pet.PetShortInfo, len(petList)),
|
||||
}
|
||||
for i := range petList {
|
||||
result.ShortInfoList[i] = buildPetShortInfo(petList[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func removePetByCatchTime(petList []model.PetInfo, catchTime uint32) []model.PetInfo {
|
||||
for i := range petList {
|
||||
if petList[i].CatchTime == catchTime {
|
||||
return append(petList[:i], petList[i+1:]...)
|
||||
}
|
||||
}
|
||||
return petList
|
||||
}
|
||||
|
||||
func buildWarehousePetList(player *player.Player) []model.PetInfo {
|
||||
allPets := player.Service.Pet.PetInfo(0)
|
||||
if len(allPets) == 0 {
|
||||
return make([]model.PetInfo, 0)
|
||||
}
|
||||
|
||||
usedCatchTimes := make(map[uint32]struct{}, len(player.Info.PetList)+len(player.Info.BackupPetList))
|
||||
for _, petInfo := range player.Info.PetList {
|
||||
usedCatchTimes[petInfo.CatchTime] = struct{}{}
|
||||
}
|
||||
for _, petInfo := range player.Info.BackupPetList {
|
||||
usedCatchTimes[petInfo.CatchTime] = struct{}{}
|
||||
}
|
||||
|
||||
result := make([]model.PetInfo, 0, len(allPets))
|
||||
for i := range allPets {
|
||||
catchTime := allPets[i].Data.CatchTime
|
||||
if _, exists := usedCatchTimes[catchTime]; exists {
|
||||
continue
|
||||
}
|
||||
result = append(result, allPets[i].Data)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func findBackupPet(player *player.Player, catchTime uint32) (int, *model.PetInfo, bool) {
|
||||
for i := range player.Info.BackupPetList {
|
||||
if player.Info.BackupPetList[i].CatchTime == catchTime {
|
||||
return i, &player.Info.BackupPetList[i], true
|
||||
}
|
||||
}
|
||||
return -1, nil, false
|
||||
}
|
||||
|
||||
func syncBackupPetList(player *player.Player) {
|
||||
if player.Info.BackupPetList == nil {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagPets := player.Service.Pet.PetInfo(0)
|
||||
if len(bagPets) == 0 {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagCatchTimes := make(map[uint32]struct{}, len(bagPets))
|
||||
for i := range bagPets {
|
||||
bagCatchTimes[bagPets[i].Data.CatchTime] = struct{}{}
|
||||
}
|
||||
|
||||
mainPetCatchTimes := make(map[uint32]struct{}, len(player.Info.PetList))
|
||||
for _, petInfo := range player.Info.PetList {
|
||||
mainPetCatchTimes[petInfo.CatchTime] = struct{}{}
|
||||
}
|
||||
|
||||
nextBackupList := make([]model.PetInfo, 0, len(player.Info.BackupPetList))
|
||||
for _, petInfo := range player.Info.BackupPetList {
|
||||
if _, inBag := bagCatchTimes[petInfo.CatchTime]; !inBag {
|
||||
continue
|
||||
}
|
||||
if _, inMain := mainPetCatchTimes[petInfo.CatchTime]; inMain {
|
||||
continue
|
||||
}
|
||||
nextBackupList = append(nextBackupList, petInfo)
|
||||
}
|
||||
player.Info.BackupPetList = nextBackupList
|
||||
}
|
||||
|
||||
func buildUserBagPetInfo(player *player.Player) *pet.GetUserBagPetInfoOutboundInfo {
|
||||
syncBackupPetList(player)
|
||||
|
||||
result := &pet.GetUserBagPetInfoOutboundInfo{
|
||||
PetList: make([]model.PetInfo, len(player.Info.PetList)),
|
||||
BackupPetList: make([]model.PetInfo, len(player.Info.BackupPetList)),
|
||||
}
|
||||
copy(result.PetList, player.Info.PetList)
|
||||
copy(result.BackupPetList, player.Info.BackupPetList)
|
||||
return result
|
||||
}
|
||||
|
||||
func buildOrderedPetList(
|
||||
catchTimes []uint32,
|
||||
petMap map[uint32]model.PetInfo,
|
||||
used map[uint32]struct{},
|
||||
) ([]model.PetInfo, bool) {
|
||||
result := make([]model.PetInfo, 0, len(catchTimes))
|
||||
for _, catchTime := range catchTimes {
|
||||
if catchTime == 0 {
|
||||
return nil, false
|
||||
}
|
||||
if _, exists := used[catchTime]; exists {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
petInfo, exists := petMap[catchTime]
|
||||
if !exists {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
used[catchTime] = struct{}{}
|
||||
result = append(result, petInfo)
|
||||
}
|
||||
return result, true
|
||||
}
|
||||
|
||||
func buildPetShowOutboundInfo(userID, flag uint32, info *model.PetInfo) *pet.PetShowOutboundInfo {
|
||||
return &pet.PetShowOutboundInfo{
|
||||
UserID: userID,
|
||||
CatchTime: info.CatchTime,
|
||||
ID: info.ID,
|
||||
Flag: flag,
|
||||
Dv: info.Dv,
|
||||
ShinyLen: info.ShinyLen,
|
||||
ShinyInfo: info.ShinyInfo,
|
||||
SkinID: info.SkinID,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPetInfo 获取精灵信息
|
||||
// data: 包含精灵捕获时间的输入信息
|
||||
// player: 当前玩家对象
|
||||
// 返回: 精灵信息和错误码
|
||||
func (h Controller) GetPetInfo(
|
||||
data *pet.InInfo,
|
||||
player *player.Player) (result *model.PetInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
_, petInfo, found := player.FindPet(data.CatchTime)
|
||||
|
||||
if found {
|
||||
result = petInfo
|
||||
return result, 0
|
||||
}
|
||||
|
||||
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if ret == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
result = &ret.Data
|
||||
return result, 0
|
||||
}
|
||||
@@ -188,56 +35,7 @@ func (h Controller) GetUserBagPetInfo(
|
||||
return buildUserBagPetInfo(player), 0
|
||||
}
|
||||
|
||||
// GetPetList 获取仓库列表
|
||||
// data: 空输入结构
|
||||
// player: 当前玩家对象
|
||||
// 返回: 精灵列表和错误码
|
||||
// SavePetBagOrder 保存当前主背包和备用背包顺序
|
||||
func (h Controller) SavePetBagOrder(
|
||||
data *pet.SavePetBagOrderInboundInfo,
|
||||
player *player.Player) (result *fight.NullOutboundInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
syncBackupPetList(player)
|
||||
|
||||
if len(data.PetList) > 6 || len(data.BackupPetList) > 6 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
totalPetCount := len(player.Info.PetList) + len(player.Info.BackupPetList)
|
||||
if len(data.PetList)+len(data.BackupPetList) != totalPetCount {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
petMap := make(map[uint32]model.PetInfo, totalPetCount)
|
||||
for _, petInfo := range player.Info.PetList {
|
||||
petMap[petInfo.CatchTime] = petInfo
|
||||
}
|
||||
for _, petInfo := range player.Info.BackupPetList {
|
||||
petMap[petInfo.CatchTime] = petInfo
|
||||
}
|
||||
|
||||
used := make(map[uint32]struct{}, totalPetCount)
|
||||
|
||||
battleList, ok := buildOrderedPetList(data.PetList, petMap, used)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
backupList, ok := buildOrderedPetList(data.BackupPetList, petMap, used)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
if len(used) != totalPetCount {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
player.Info.PetList = battleList
|
||||
player.Info.BackupPetList = backupList
|
||||
player.Service.Info.Save(*player.Info)
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
// GetPetList 获取当前主背包列表
|
||||
func (h Controller) GetPetList(
|
||||
data *pet.GetPetListInboundEmpty,
|
||||
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
||||
@@ -245,10 +43,7 @@ func (h Controller) GetPetList(
|
||||
return buildPetListOutboundInfo(player.Info.PetList), 0
|
||||
}
|
||||
|
||||
// GetPetReleaseList 获取放生列表
|
||||
// data: 空输入结构
|
||||
// player: 当前玩家对象
|
||||
// 返回: 放生精灵列表和错误码
|
||||
// GetPetReleaseList 获取仓库可放生列表
|
||||
func (h Controller) GetPetReleaseList(
|
||||
data *pet.GetPetListFreeInboundEmpty,
|
||||
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
||||
@@ -257,191 +52,17 @@ func (h Controller) GetPetReleaseList(
|
||||
return buildPetListOutboundInfo(buildWarehousePetList(player)), 0
|
||||
}
|
||||
|
||||
// PetReleaseToWarehouse 将精灵从仓库包中放生
|
||||
// data: 包含精灵ID和捕获时间的输入信息
|
||||
// player: 当前玩家对象
|
||||
// 返回: 无数据和错误码
|
||||
func (h Controller) PetReleaseToWarehouse(
|
||||
data *pet.PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, _, inBag := player.FindPet(data.CatchTime)
|
||||
_, _, inBackup := findBackupPet(player, data.CatchTime)
|
||||
freeForbidden := xmlres.PetMAP[int(data.ID)].FreeForbidden
|
||||
// 如果背包没找到,再放入背包
|
||||
if inBag || inBackup || freeForbidden == 1 {
|
||||
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
|
||||
}
|
||||
|
||||
if !player.Service.Pet.UpdateFree(data.CatchTime, 1) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
return nil, err
|
||||
|
||||
}
|
||||
|
||||
// PetRetrieveFromWarehouse 领回包
|
||||
func (h Controller) PetRetrieveFromWarehouse(
|
||||
data *pet.PET_RETRIEVE, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
//如果背包没找到,再放入背包
|
||||
if _, _, ok := player.FindPet(data.CatchTime); !ok {
|
||||
if petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime); petInfo != nil {
|
||||
syncBackupPetList(player)
|
||||
if len(player.Info.PetList) < 6 {
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
} else if len(player.Info.BackupPetList) < 6 {
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
|
||||
}
|
||||
player.Service.Info.Save(*player.Info)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
|
||||
}
|
||||
|
||||
// TogglePetBagWarehouse 精灵背包仓库切换
|
||||
func (h Controller) TogglePetBagWarehouse(
|
||||
data *pet.PetReleaseInboundInfo,
|
||||
player *player.Player) (result *pet.PetReleaseOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &pet.PetReleaseOutboundInfo{}
|
||||
result.Flag = uint32(data.Flag)
|
||||
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
syncBackupPetList(player)
|
||||
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
if index, currentPet, ok := player.FindPet(data.CatchTime); ok {
|
||||
if index < 0 || index >= len(player.Info.PetList) {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if !player.Service.Pet.Update(*currentPet) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
player.Info.PetList = append(player.Info.PetList[:index], player.Info.PetList[index+1:]...)
|
||||
player.Service.Info.Save(*player.Info)
|
||||
break
|
||||
}
|
||||
|
||||
index, currentPet, ok := findBackupPet(player, data.CatchTime)
|
||||
if !ok {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
if index < 0 || index >= len(player.Info.BackupPetList) {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if !player.Service.Pet.Update(*currentPet) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList[:index], player.Info.BackupPetList[index+1:]...)
|
||||
|
||||
case 1:
|
||||
if len(player.Info.PetList) >= 6 && len(player.Info.BackupPetList) >= 6 {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
if _, _, ok := player.FindPet(data.CatchTime); ok {
|
||||
return result, 0
|
||||
}
|
||||
if _, _, ok := findBackupPet(player, data.CatchTime); ok {
|
||||
return result, 0
|
||||
}
|
||||
|
||||
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if petInfo == nil {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
if len(player.Info.PetList) < 6 {
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
} else {
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
|
||||
}
|
||||
result.PetInfo = petInfo.Data
|
||||
|
||||
}
|
||||
|
||||
if len(player.Info.PetList) > 0 {
|
||||
result.FirstPetTime = player.Info.PetList[0].CatchTime
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
func (h Controller) TogglePetBagWarehouseLegacy(
|
||||
data *pet.PetReleaseLegacyInboundInfo,
|
||||
player *player.Player) (
|
||||
result *pet.PetReleaseOutboundInfo,
|
||||
err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
//放入背包=数据库置1+添加到背包+pet release发包 仓库=数据库置0+移除背包 设置首发等于取到首发精灵后重新排序
|
||||
//这里只修改,因为添加和移除背包在宠物获取时已经做了
|
||||
|
||||
result = &pet.PetReleaseOutboundInfo{}
|
||||
result.Flag = uint32(data.Flag)
|
||||
//擂台住不能换精灵
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
|
||||
index, pet, ok := player.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
// ========== 新增:index合法性校验 ==========
|
||||
if index < 0 || index >= len(player.Info.PetList) {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
}
|
||||
|
||||
if !player.Service.Pet.Update(*pet) {
|
||||
return result, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
player.Info.BackupPetList = removePetByCatchTime(player.Info.BackupPetList, data.CatchTime)
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, *pet)
|
||||
player.Info.PetList = append(player.Info.PetList[:index], player.Info.PetList[index+1:]...)
|
||||
}
|
||||
|
||||
// break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
|
||||
case 1:
|
||||
if len(player.Info.PetList) < 6 {
|
||||
//todo 背包
|
||||
_, _, ok := player.FindPet(data.CatchTime)
|
||||
|
||||
//如果背包没找到,再放入背包
|
||||
if !ok {
|
||||
r := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if r == nil {
|
||||
return result, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
player.Info.PetList = append(player.Info.PetList, r.Data)
|
||||
player.Info.BackupPetList = removePetByCatchTime(player.Info.BackupPetList, data.CatchTime)
|
||||
result.PetInfo = r.Data
|
||||
} else {
|
||||
player.Info.BackupPetList = removePetByCatchTime(player.Info.BackupPetList, data.CatchTime)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(player.Info.PetList) > 0 {
|
||||
result.FirstPetTime = player.Info.PetList[0].CatchTime //设置首发
|
||||
}
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// PlayerShowPet 精灵展示
|
||||
func (h Controller) PlayerShowPet(
|
||||
data *pet.PetShowInboundInfo, player *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
data *pet.PetShowInboundInfo,
|
||||
player *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &pet.PetShowOutboundInfo{
|
||||
UserID: data.Head.UserID,
|
||||
CatchTime: data.CatchTime,
|
||||
Flag: data.Flag,
|
||||
}
|
||||
_, currentPet, ok := player.FindPet(data.CatchTime)
|
||||
|
||||
_, currentPet, ok := player.FindPet(data.CatchTime)
|
||||
if data.Flag == 0 {
|
||||
player.SetPetDisplay(0, nil)
|
||||
player.GetSpace().RefreshUserInfo(player)
|
||||
@@ -458,57 +79,4 @@ func (h Controller) PlayerShowPet(
|
||||
result = buildPetShowOutboundInfo(data.Head.UserID, data.Flag, currentPet)
|
||||
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
// PetOneCure 单体治疗
|
||||
func (h Controller) PetOneCure(
|
||||
data *pet.PetOneCureInboundInfo, player *player.Player) (result *pet.PetOneCureOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
if player.IsArenaHealLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotHeal
|
||||
}
|
||||
|
||||
_, currentPet, ok := player.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
defer currentPet.Cure()
|
||||
|
||||
}
|
||||
|
||||
return &pet.PetOneCureOutboundInfo{
|
||||
CatchTime: data.CatchTime,
|
||||
}, 0
|
||||
|
||||
}
|
||||
|
||||
// PetFirst 精灵首发
|
||||
func (h Controller) PetFirst(
|
||||
data *pet.PetDefaultInboundInfo, player *player.Player) (result *pet.PetDefaultOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
//擂台住不能换精灵
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
result = &pet.PetDefaultOutboundInfo{}
|
||||
|
||||
index, _, ok := player.FindPet(data.CatchTime)
|
||||
if ok && index != 0 {
|
||||
|
||||
player.Info.PetList[index], player.Info.PetList[0] = player.Info.PetList[0], player.Info.PetList[index]
|
||||
|
||||
result.IsDefault = 1
|
||||
}
|
||||
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// SetPetExp 设置宠物经验
|
||||
func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, player *player.Player) (result *pet.PetSetExpOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, found := player.FindPet(data.CatchTime)
|
||||
if found && currentPet.Level < 100 {
|
||||
player.AddPetExp(currentPet, data.Exp)
|
||||
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, 0
|
||||
}
|
||||
|
||||
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
220
logic/controller/pet_info_helpers.go
Normal file
220
logic/controller/pet_info_helpers.go
Normal file
@@ -0,0 +1,220 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type petListKind uint8
|
||||
|
||||
const (
|
||||
petListKindMain petListKind = iota
|
||||
petListKindBackup
|
||||
)
|
||||
|
||||
type petListSlot struct {
|
||||
list *[]model.PetInfo
|
||||
index int
|
||||
info model.PetInfo
|
||||
kind petListKind
|
||||
}
|
||||
|
||||
func (slot petListSlot) isValid() bool {
|
||||
return slot.list != nil && slot.index >= 0 && slot.index < len(*slot.list)
|
||||
}
|
||||
|
||||
func (slot petListSlot) remove() {
|
||||
*slot.list = append((*slot.list)[:slot.index], (*slot.list)[slot.index+1:]...)
|
||||
}
|
||||
|
||||
func buildPetShortInfo(info model.PetInfo) pet.PetShortInfo {
|
||||
return pet.PetShortInfo{
|
||||
ID: info.ID,
|
||||
CatchTime: info.CatchTime,
|
||||
Level: info.Level,
|
||||
SkinID: info.SkinID,
|
||||
ShinyLen: info.ShinyLen,
|
||||
ShinyInfo: info.ShinyInfo,
|
||||
}
|
||||
}
|
||||
|
||||
func buildPetListOutboundInfo(petList []model.PetInfo) *pet.GetPetListOutboundInfo {
|
||||
result := &pet.GetPetListOutboundInfo{
|
||||
ShortInfoList: make([]pet.PetShortInfo, len(petList)),
|
||||
}
|
||||
for i := range petList {
|
||||
result.ShortInfoList[i] = buildPetShortInfo(petList[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func removePetByCatchTime(petList []model.PetInfo, catchTime uint32) []model.PetInfo {
|
||||
for i := range petList {
|
||||
if petList[i].CatchTime == catchTime {
|
||||
return append(petList[:i], petList[i+1:]...)
|
||||
}
|
||||
}
|
||||
return petList
|
||||
}
|
||||
|
||||
func buildCatchTimeSet(petLists ...[]model.PetInfo) map[uint32]struct{} {
|
||||
total := 0
|
||||
for _, petList := range petLists {
|
||||
total += len(petList)
|
||||
}
|
||||
|
||||
catchTimes := make(map[uint32]struct{}, total)
|
||||
for _, petList := range petLists {
|
||||
for _, petInfo := range petList {
|
||||
catchTimes[petInfo.CatchTime] = struct{}{}
|
||||
}
|
||||
}
|
||||
return catchTimes
|
||||
}
|
||||
|
||||
func buildPetInfoMap(petLists ...[]model.PetInfo) map[uint32]model.PetInfo {
|
||||
total := 0
|
||||
for _, petList := range petLists {
|
||||
total += len(petList)
|
||||
}
|
||||
|
||||
petMap := make(map[uint32]model.PetInfo, total)
|
||||
for _, petList := range petLists {
|
||||
for _, petInfo := range petList {
|
||||
petMap[petInfo.CatchTime] = petInfo
|
||||
}
|
||||
}
|
||||
return petMap
|
||||
}
|
||||
|
||||
func buildWarehousePetList(player *player.Player) []model.PetInfo {
|
||||
allPets := player.Service.Pet.PetInfo(0)
|
||||
if len(allPets) == 0 {
|
||||
return make([]model.PetInfo, 0)
|
||||
}
|
||||
|
||||
usedCatchTimes := buildCatchTimeSet(player.Info.PetList, player.Info.BackupPetList)
|
||||
result := make([]model.PetInfo, 0, len(allPets))
|
||||
for i := range allPets {
|
||||
catchTime := allPets[i].Data.CatchTime
|
||||
if _, exists := usedCatchTimes[catchTime]; exists {
|
||||
continue
|
||||
}
|
||||
result = append(result, allPets[i].Data)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func findBackupPet(player *player.Player, catchTime uint32) (int, *model.PetInfo, bool) {
|
||||
for i := range player.Info.BackupPetList {
|
||||
if player.Info.BackupPetList[i].CatchTime == catchTime {
|
||||
return i, &player.Info.BackupPetList[i], true
|
||||
}
|
||||
}
|
||||
return -1, nil, false
|
||||
}
|
||||
|
||||
func findPetListSlot(player *player.Player, catchTime uint32) (petListSlot, bool) {
|
||||
if index, petInfo, ok := player.FindPet(catchTime); ok {
|
||||
return petListSlot{
|
||||
list: &player.Info.PetList,
|
||||
index: index,
|
||||
info: *petInfo,
|
||||
kind: petListKindMain,
|
||||
}, true
|
||||
}
|
||||
|
||||
if index, petInfo, ok := findBackupPet(player, catchTime); ok {
|
||||
return petListSlot{
|
||||
list: &player.Info.BackupPetList,
|
||||
index: index,
|
||||
info: *petInfo,
|
||||
kind: petListKindBackup,
|
||||
}, true
|
||||
}
|
||||
|
||||
return petListSlot{}, false
|
||||
}
|
||||
|
||||
func syncBackupPetList(player *player.Player) {
|
||||
if player.Info.BackupPetList == nil {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagPets := player.Service.Pet.PetInfo(0)
|
||||
if len(bagPets) == 0 {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagCatchTimes := make(map[uint32]struct{}, len(bagPets))
|
||||
for i := range bagPets {
|
||||
bagCatchTimes[bagPets[i].Data.CatchTime] = struct{}{}
|
||||
}
|
||||
|
||||
mainPetCatchTimes := buildCatchTimeSet(player.Info.PetList)
|
||||
nextBackupList := make([]model.PetInfo, 0, len(player.Info.BackupPetList))
|
||||
for _, petInfo := range player.Info.BackupPetList {
|
||||
if _, inBag := bagCatchTimes[petInfo.CatchTime]; !inBag {
|
||||
continue
|
||||
}
|
||||
if _, inMain := mainPetCatchTimes[petInfo.CatchTime]; inMain {
|
||||
continue
|
||||
}
|
||||
nextBackupList = append(nextBackupList, petInfo)
|
||||
}
|
||||
|
||||
player.Info.BackupPetList = nextBackupList
|
||||
}
|
||||
|
||||
func buildUserBagPetInfo(player *player.Player) *pet.GetUserBagPetInfoOutboundInfo {
|
||||
syncBackupPetList(player)
|
||||
|
||||
result := &pet.GetUserBagPetInfoOutboundInfo{
|
||||
PetList: make([]model.PetInfo, len(player.Info.PetList)),
|
||||
BackupPetList: make([]model.PetInfo, len(player.Info.BackupPetList)),
|
||||
}
|
||||
copy(result.PetList, player.Info.PetList)
|
||||
copy(result.BackupPetList, player.Info.BackupPetList)
|
||||
return result
|
||||
}
|
||||
|
||||
func buildOrderedPetList(
|
||||
catchTimes []uint32,
|
||||
petMap map[uint32]model.PetInfo,
|
||||
used map[uint32]struct{},
|
||||
) ([]model.PetInfo, bool) {
|
||||
result := make([]model.PetInfo, 0, len(catchTimes))
|
||||
for _, catchTime := range catchTimes {
|
||||
if catchTime == 0 {
|
||||
return nil, false
|
||||
}
|
||||
if _, exists := used[catchTime]; exists {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
petInfo, exists := petMap[catchTime]
|
||||
if !exists {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
used[catchTime] = struct{}{}
|
||||
result = append(result, petInfo)
|
||||
}
|
||||
return result, true
|
||||
}
|
||||
|
||||
func buildPetShowOutboundInfo(userID, flag uint32, info *model.PetInfo) *pet.PetShowOutboundInfo {
|
||||
return &pet.PetShowOutboundInfo{
|
||||
UserID: userID,
|
||||
CatchTime: info.CatchTime,
|
||||
ID: info.ID,
|
||||
Flag: flag,
|
||||
Dv: info.Dv,
|
||||
ShinyLen: info.ShinyLen,
|
||||
ShinyInfo: info.ShinyInfo,
|
||||
SkinID: info.SkinID,
|
||||
}
|
||||
}
|
||||
73
logic/controller/pet_manage.go
Normal file
73
logic/controller/pet_manage.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// PetReleaseToWarehouse 将精灵从仓库包中放生
|
||||
func (h Controller) PetReleaseToWarehouse(
|
||||
data *pet.PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, _, inBag := player.FindPet(data.CatchTime)
|
||||
_, _, inBackup := findBackupPet(player, data.CatchTime)
|
||||
freeForbidden := xmlres.PetMAP[int(data.ID)].FreeForbidden
|
||||
if inBag || inBackup || freeForbidden == 1 {
|
||||
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
|
||||
}
|
||||
|
||||
if !player.Service.Pet.UpdateFree(data.CatchTime, 1) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
// PetOneCure 单体治疗
|
||||
func (h Controller) PetOneCure(
|
||||
data *pet.PetOneCureInboundInfo, player *player.Player) (result *pet.PetOneCureOutboundInfo, err errorcode.ErrorCode) {
|
||||
if player.IsArenaHealLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotHeal
|
||||
}
|
||||
|
||||
_, currentPet, ok := player.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
defer currentPet.Cure()
|
||||
}
|
||||
|
||||
return &pet.PetOneCureOutboundInfo{
|
||||
CatchTime: data.CatchTime,
|
||||
}, 0
|
||||
}
|
||||
|
||||
// PetFirst 精灵首发
|
||||
func (h Controller) PetFirst(
|
||||
data *pet.PetDefaultInboundInfo, player *player.Player) (result *pet.PetDefaultOutboundInfo, err errorcode.ErrorCode) {
|
||||
if player.IsArenaSwitchLocked() {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
result = &pet.PetDefaultOutboundInfo{}
|
||||
index, _, ok := player.FindPet(data.CatchTime)
|
||||
if ok && index != 0 {
|
||||
player.Info.PetList[index], player.Info.PetList[0] = player.Info.PetList[0], player.Info.PetList[index]
|
||||
result.IsDefault = 1
|
||||
}
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
// SetPetExp 设置宠物经验
|
||||
func (h Controller) SetPetExp(
|
||||
data *pet.PetSetExpInboundInfo,
|
||||
player *player.Player) (result *pet.PetSetExpOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, found := player.FindPet(data.CatchTime)
|
||||
if !found || currentPet.Level >= 100 {
|
||||
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
player.AddPetExp(currentPet, data.Exp)
|
||||
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, 0
|
||||
}
|
||||
@@ -29,6 +29,7 @@ func (f *FightC) openActionWindow() {
|
||||
f.actionMu.Lock()
|
||||
f.acceptActions = true
|
||||
f.pendingActions = f.pendingActions[:0]
|
||||
f.actionRound.Store(uint32(f.Round))
|
||||
f.actionMu.Unlock()
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ func (f *FightC) closeActionWindow() {
|
||||
f.actionMu.Lock()
|
||||
f.acceptActions = false
|
||||
f.pendingActions = f.pendingActions[:0]
|
||||
f.actionRound.Store(0)
|
||||
f.actionMu.Unlock()
|
||||
}
|
||||
|
||||
@@ -44,8 +46,14 @@ func (f *FightC) submitAction(act action.BattleActionI) {
|
||||
return
|
||||
}
|
||||
|
||||
round := f.actionRound.Load()
|
||||
if round == 0 {
|
||||
return
|
||||
}
|
||||
act.SetRound(round)
|
||||
|
||||
f.actionMu.Lock()
|
||||
if !f.acceptActions {
|
||||
if !f.acceptActions || act.GetRound() != f.actionRound.Load() {
|
||||
f.actionMu.Unlock()
|
||||
return
|
||||
}
|
||||
@@ -200,7 +208,6 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if f.Info.Mode == info.BattleMode.PET_MELEE {
|
||||
go f.UseSkill(c, 0)
|
||||
return
|
||||
@@ -258,13 +265,9 @@ func (f *FightC) startBattle(startInfo info.FightStartOutboundInfo) {
|
||||
// }
|
||||
go f.battleLoop()
|
||||
|
||||
// 向双方广播战斗开始信息
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
// 通知双方玩家准备完成,即将开始战斗
|
||||
|
||||
ff.Player.SendPackCmd(2504, &startInfo)
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ var PlayerOperations = enum.New[struct {
|
||||
// BattleActionI 战斗动作接口
|
||||
type BattleActionI interface {
|
||||
GetPlayerID() uint32
|
||||
GetRound() uint32
|
||||
SetRound(uint32)
|
||||
Priority() int // 优先级
|
||||
|
||||
}
|
||||
|
||||
// SelectSkillAction 选择技能的战斗动作
|
||||
@@ -43,21 +44,29 @@ func (*SelectSkillAction) Priority() int {
|
||||
|
||||
type BaseAction struct {
|
||||
PlayerID uint32 // 玩家ID
|
||||
|
||||
Round uint32 // 所属回合
|
||||
}
|
||||
|
||||
func NewBaseAction(t uint32) BaseAction {
|
||||
return BaseAction{
|
||||
PlayerID: t,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (a *BaseAction) GetPlayerID() uint32 {
|
||||
return a.PlayerID
|
||||
// fmt.Printf("玩家[%d]主动切换宠物:从%s切换到%s(原因:%s)\n",
|
||||
// // a.PlayerID, a.CurrentPet.Name, a.TargetPet.Name, a.SwitchReason)
|
||||
}
|
||||
|
||||
func (a *BaseAction) GetRound() uint32 {
|
||||
return a.Round
|
||||
}
|
||||
|
||||
func (a *BaseAction) SetRound(round uint32) {
|
||||
a.Round = round
|
||||
}
|
||||
|
||||
// ActiveSwitchAction 主动切换宠物的战斗动作
|
||||
type ActiveSwitchAction struct {
|
||||
BaseAction
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 137: 损失一半当前体力值,自身攻击和速度提升2个等级
|
||||
type Effect137 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect137) OnSkill() bool {
|
||||
// 损失一半当前体力值
|
||||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||||
halfHp := currentHp.Div(alpacadecimal.NewFromInt(2))
|
||||
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: halfHp,
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, damageZone)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 2)
|
||||
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 0, 2)
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 137, &Effect137{})
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// Effect 1380: 牺牲自身全部体力,使对手全属性-{0}且{1}回合内先制-{2}
|
||||
type Effect1380 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1380) Skill_Use() bool {
|
||||
if len(e.Args()) < 3 {
|
||||
return true
|
||||
}
|
||||
|
||||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1380, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetHP(),
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1380Sub struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1380Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||||
if current == nil || current.SkillEntity == nil || len(e.Args()) < 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
current.SkillEntity.XML.Priority -= int(e.Args()[1].IntPart())
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1380, &Effect1380{})
|
||||
input.InitEffect(input.EffectType.Sub, 1380, &Effect1380Sub{})
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// Effect 142: 损失1/{0}的体力值,下回合能较快出手
|
||||
type Effect142 struct {
|
||||
node.EffectNode
|
||||
can bool
|
||||
}
|
||||
|
||||
func (e *Effect142) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||||
|
||||
if fattack == nil {
|
||||
return true
|
||||
}
|
||||
//先手是自己
|
||||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if sattack.SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
//对调
|
||||
sattack.SkillEntity.XML.Priority += 1
|
||||
return true
|
||||
}
|
||||
func (e *Effect142) OnSkill() bool {
|
||||
// 损失1/n的体力值
|
||||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||||
damageAmount := maxHp.Div(e.Args()[0]) // 1/n
|
||||
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damageAmount,
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 142, &Effect142{})
|
||||
|
||||
}
|
||||
@@ -43,16 +43,18 @@ func (e *Effect1428) Skill_Use() bool {
|
||||
|
||||
type Effect1428Sub struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1428Sub) TurnEnd() bool {
|
||||
func (e *Effect1428Sub) TurnEnd() {
|
||||
if len(e.Args()) < 2 {
|
||||
return true
|
||||
e.EffectNode.TurnEnd()
|
||||
return
|
||||
}
|
||||
statusID := int(e.Args()[1].IntPart())
|
||||
if statusID <= 0 {
|
||||
return true
|
||||
e.EffectNode.TurnEnd()
|
||||
return
|
||||
}
|
||||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
||||
return true
|
||||
e.EffectNode.TurnEnd()
|
||||
}
|
||||
|
||||
// Effect 1429: 50%的概率打出致命一击,未触发则{0}%令对手{1}
|
||||
|
||||
179
logic/service/fight/effect/1438_1442.go
Normal file
179
logic/service/fight/effect/1438_1442.go
Normal file
@@ -0,0 +1,179 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 1438: 若对手处于能力下降状态,则{0}回合内令对手使用的属性技能无效
|
||||
type Effect1438 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1438) Skill_Use() bool {
|
||||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 || !e.Ctx().Opp.HasPropSub() {
|
||||
return true
|
||||
}
|
||||
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1438, int(e.Args()[0].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1438Sub struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1438Sub) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().SkillEntity.SetMiss()
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1439: 对手处于能力下降状态造成的伤害提升{0}%
|
||||
type Effect1439 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1439) Damage_Mul(zone *info.DamageZone) bool {
|
||||
if len(e.Args()) == 0 || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
if !e.Ctx().Opp.HasPropSub() {
|
||||
return true
|
||||
}
|
||||
|
||||
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[0])).Div(hundred)
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1440: 免疫下{0}次自身受到的异常状态
|
||||
type Effect1440 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1440) Skill_Use() bool {
|
||||
if len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1440, int(e.Args()[0].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1440Sub struct {
|
||||
node.EffectNode
|
||||
remaining int
|
||||
}
|
||||
|
||||
func (e *Effect1440Sub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1)
|
||||
e.CanStack(false)
|
||||
if len(a) > 0 {
|
||||
e.remaining = a[0]
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Effect1440Sub) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
if e.remaining <= 0 {
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
if in != e.Ctx().Opp || !input.IS_Stat(effEffect) {
|
||||
return true
|
||||
}
|
||||
|
||||
e.remaining--
|
||||
if e.remaining <= 0 {
|
||||
e.Alive(false)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Effect 1441: 解除自身能力下降状态,解除成功则使对手随机{0}个技能PP值归零
|
||||
type Effect1441 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1441) Skill_Use() bool {
|
||||
cleared := false
|
||||
for i, v := range e.Ctx().Our.Prop[:] {
|
||||
if v >= 0 {
|
||||
continue
|
||||
}
|
||||
if e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), 0) {
|
||||
cleared = true
|
||||
}
|
||||
}
|
||||
if cleared && len(e.Args()) > 0 {
|
||||
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[0].IntPart()))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1442: {0}回合内每回合{1}%闪避对手攻击,未触发则回合结束时{2}%令对手{3}
|
||||
type Effect1442 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1442) Skill_Use() bool {
|
||||
if len(e.Args()) < 4 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1442, e.SideEffectArgs...)
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1442Sub struct {
|
||||
node.EffectNode
|
||||
triggered bool
|
||||
}
|
||||
|
||||
func (e *Effect1442Sub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.CanStack(false)
|
||||
if len(a) > 0 {
|
||||
e.Duration(a[0])
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Effect1442Sub) SkillHit_ex() bool {
|
||||
if len(e.Args()) < 4 || e.triggered || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 || e.Ctx().SkillEntity.AttackTime == 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok && e.Ctx().SkillEntity.SetMiss() {
|
||||
e.triggered = true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1442Sub) TurnEnd() {
|
||||
if !e.triggered && len(e.Args()) >= 4 {
|
||||
statusID := int(e.Args()[3].IntPart())
|
||||
if statusID > 0 {
|
||||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok {
|
||||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.triggered = false
|
||||
e.EffectNode.TurnEnd()
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1438, &Effect1438{})
|
||||
input.InitEffect(input.EffectType.Sub, 1438, &Effect1438Sub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1439, &Effect1439{})
|
||||
input.InitEffect(input.EffectType.Skill, 1440, &Effect1440{})
|
||||
input.InitEffect(input.EffectType.Sub, 1440, &Effect1440Sub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1441, &Effect1441{})
|
||||
input.InitEffect(input.EffectType.Skill, 1442, &Effect1442{})
|
||||
input.InitEffect(input.EffectType.Sub, 1442, &Effect1442Sub{})
|
||||
}
|
||||
170
logic/service/fight/effect/1443_1447.go
Normal file
170
logic/service/fight/effect/1443_1447.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 1443: 连续使用时威力提升{0}%,最高提升{1}%
|
||||
type Effect1443 struct{ AddLvelEffect }
|
||||
|
||||
func (e *Effect1443) SkillHit() bool {
|
||||
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
if (e.Skillid != 0 && e.Ctx().SkillEntity.XML.ID != e.Skillid) || e.Ctx().SkillEntity.AttackTime == 0 {
|
||||
return e.AddLvelEffect.SkillHit()
|
||||
}
|
||||
if e.UseSkillCount > 0 {
|
||||
addSkillPowerPercent(e.Ctx().SkillEntity, e.GetStackOnlyADD(e.Args()[0], e.Args()[1]))
|
||||
}
|
||||
return e.AddLvelEffect.SkillHit()
|
||||
}
|
||||
|
||||
// Effect 1444: 威力根据自身体力变化,当前剩余体力越少则威力越大
|
||||
type Effect1444 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1444) SkillHit() bool {
|
||||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Our.CurrentPet == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||||
if maxHP.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
power := alpacadecimal.NewFromInt(165).Sub(e.Ctx().Our.CurrentPet.GetHP().Div(maxHP).Mul(alpacadecimal.NewFromInt(65)))
|
||||
if power.Cmp(alpacadecimal.Zero) > 0 {
|
||||
e.Ctx().SkillEntity.XML.Power = int(power.IntPart())
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1445: 吸取对手能力提升状态,吸取成功则{0}回合内对手属性技能无效,若对手不处于能力提升状态则自身下{1}回合先制+{2}
|
||||
type Effect1445 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1445) Skill_Use() bool {
|
||||
if len(e.Args()) < 3 {
|
||||
return true
|
||||
}
|
||||
|
||||
absorbed := false
|
||||
for i, v := range e.Ctx().Opp.Prop[:] {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
if !e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0) {
|
||||
continue
|
||||
}
|
||||
absorbed = true
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
|
||||
}
|
||||
if absorbed {
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 14450, int(e.Args()[0].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 14451, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1445StatusDisableSub struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1445StatusDisableSub) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().SkillEntity.SetMiss()
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1445PrioritySub struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1445PrioritySub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||||
if !shouldAdjustNextAttackPriority(e, fattack, sattack) || len(e.Args()) < 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
sattack.SkillEntity.XML.Priority += int(e.Args()[1].IntPart())
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1446: 获得{0}点护罩,护罩消失时使对手全属性-{1}
|
||||
type Effect1446 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1446) Skill_Use() bool {
|
||||
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.AddShield(e.Args()[0])
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1446, int(e.Args()[1].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1446Sub struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1446Sub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1)
|
||||
e.CanStack(false)
|
||||
}
|
||||
|
||||
func (e *Effect1446Sub) ShieldChange(before, after alpacadecimal.Decimal) bool {
|
||||
if before.Cmp(alpacadecimal.Zero) <= 0 || after.Cmp(alpacadecimal.Zero) > 0 {
|
||||
return true
|
||||
}
|
||||
if len(e.Args()) > 0 {
|
||||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
|
||||
}
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1447: 自身体力高于最大体力的1/{0}时{1}%令对手{2}
|
||||
type Effect1447 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1447) Skill_Use() bool {
|
||||
if len(e.Args()) < 3 || e.Ctx().Our.CurrentPet == nil || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||||
if maxHP.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().Our.CurrentPet.GetHP().Mul(e.Args()[0]).Cmp(maxHP) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
|
||||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[2].IntPart()))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1443, &Effect1443{})
|
||||
input.InitEffect(input.EffectType.Skill, 1444, &Effect1444{})
|
||||
input.InitEffect(input.EffectType.Skill, 1445, &Effect1445{})
|
||||
input.InitEffect(input.EffectType.Sub, 14450, &Effect1445StatusDisableSub{})
|
||||
input.InitEffect(input.EffectType.Sub, 14451, &Effect1445PrioritySub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1446, &Effect1446{})
|
||||
input.InitEffect(input.EffectType.Sub, 1446, &Effect1446Sub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1447, &Effect1447{})
|
||||
}
|
||||
331
logic/service/fight/effect/1513_1517.go
Normal file
331
logic/service/fight/effect/1513_1517.go
Normal file
@@ -0,0 +1,331 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
const effect1514SpecialPetName = "混元天尊"
|
||||
|
||||
var effect151xBahuangMaxHPLoss = alpacadecimal.NewFromInt(20)
|
||||
|
||||
func reduceCurrentPetMaxHPFlat(target *input.Input, loss alpacadecimal.Decimal) bool {
|
||||
if target == nil || target.CurrentPet == nil || loss.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
currentMax := target.CurrentPet.GetMaxHP()
|
||||
if currentMax.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
newMax := currentMax.Sub(loss)
|
||||
if newMax.Cmp(alpacadecimal.NewFromInt(1)) < 0 {
|
||||
newMax = alpacadecimal.NewFromInt(1)
|
||||
}
|
||||
if newMax.Cmp(currentMax) >= 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
target.CurrentPet.Info.MaxHp = uint32(newMax.IntPart())
|
||||
if target.CurrentPet.Info.Hp > target.CurrentPet.Info.MaxHp {
|
||||
target.CurrentPet.Info.Hp = target.CurrentPet.Info.MaxHp
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1513: {0}回合内{1}%令对手{2},未触发则削减对手{3}点体力上限
|
||||
type Effect1513 struct{ RoundEffectArg0Base }
|
||||
|
||||
func (e *Effect1513) OnSkill() bool {
|
||||
if len(e.Args()) < 4 {
|
||||
return true
|
||||
}
|
||||
|
||||
statusID := int(e.Args()[2].IntPart())
|
||||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
|
||||
if statusID > 0 {
|
||||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, e.Args()[3])
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1514: 消耗自身所有体力,令自身下只登场精灵获得2次八荒之力效果,若自身下只登场精灵为混元天尊则转变为3次
|
||||
type Effect1514 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1514) Skill_Use() bool {
|
||||
if e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.Ctx().Our.CurrentPet.GetHP()})
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1514)
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1514PendingSub struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1514PendingSub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1)
|
||||
e.CanStack(false)
|
||||
}
|
||||
|
||||
func (e *Effect1514PendingSub) SwitchIn(in *input.Input) bool {
|
||||
if in != e.Ctx().Our || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
remaining := 2
|
||||
if e.Ctx().Our.CurrentPet.Info.Name == effect1514SpecialPetName {
|
||||
remaining = 3
|
||||
}
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 15141, remaining)
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1514BahuangSub struct {
|
||||
node.EffectNode
|
||||
trackedPet *info.BattlePetEntity
|
||||
remaining int
|
||||
active bool
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1)
|
||||
e.CanStack(false)
|
||||
e.trackedPet = t.CurrentPet
|
||||
if len(a) > 0 {
|
||||
e.remaining = a[0]
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||||
if e.trackedPet == nil || e.Ctx().Our.CurrentPet != e.trackedPet || e.remaining <= 0 {
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||||
if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
current.SkillEntity.XML.Priority += 1
|
||||
e.active = true
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) Damage_Mul(zone *info.DamageZone) bool {
|
||||
if !e.active || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(150)).Div(hundred)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) OnSkill() bool {
|
||||
if !e.active || e.remaining <= 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, effect151xBahuangMaxHPLoss)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) finish() bool {
|
||||
if !e.active {
|
||||
return true
|
||||
}
|
||||
|
||||
e.remaining--
|
||||
e.active = false
|
||||
if e.remaining <= 0 {
|
||||
e.Alive(false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1514BahuangSub) Action_end() bool { return e.finish() }
|
||||
func (e *Effect1514BahuangSub) Action_end_ex() bool { return e.finish() }
|
||||
|
||||
func (e *Effect1514BahuangSub) SwitchOut(in *input.Input) bool {
|
||||
if in == e.Ctx().Our {
|
||||
e.Alive(false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1515: 对手体力上限高于{0}则造成的攻击伤害提升{1}%,对手体力上限低于{2}则附加自身{3}值{4}%的百分比伤害
|
||||
type Effect1515 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1515) Damage_Mul(zone *info.DamageZone) bool {
|
||||
if len(e.Args()) < 5 || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().Opp.CurrentPet.GetMaxHP().Cmp(e.Args()[0]) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1515) OnSkill() bool {
|
||||
if len(e.Args()) < 5 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().Opp.CurrentPet.GetMaxHP().Cmp(e.Args()[2]) >= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
propID := int(e.Args()[3].IntPart())
|
||||
if propID < 0 || propID >= 6 {
|
||||
return true
|
||||
}
|
||||
|
||||
damage := e.Ctx().Our.GetProp(propID).Mul(e.Args()[4]).Div(hundred)
|
||||
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1516: 汇聚无尽的怨气,使用后下3回合自身获得八荒之力效果
|
||||
type Effect1516 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1516) Skill_Use() bool {
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1516)
|
||||
if sub != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1516Sub struct {
|
||||
node.EffectNode
|
||||
trackedPet *info.BattlePetEntity
|
||||
active bool
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(3)
|
||||
e.CanStack(false)
|
||||
e.trackedPet = t.CurrentPet
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||||
if e.trackedPet == nil || e.Ctx().Our.CurrentPet != e.trackedPet {
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||||
if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
current.SkillEntity.XML.Priority += 1
|
||||
e.active = true
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) Damage_Mul(zone *info.DamageZone) bool {
|
||||
if !e.active || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
|
||||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(150)).Div(hundred)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) OnSkill() bool {
|
||||
if !e.active || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, effect151xBahuangMaxHPLoss)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) Action_end() bool {
|
||||
e.active = false
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) Action_end_ex() bool {
|
||||
e.active = false
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect1516Sub) SwitchOut(in *input.Input) bool {
|
||||
if in == e.Ctx().Our {
|
||||
e.Alive(false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 1517: 当回合击败对手则削减对手下只登场精灵{0}点体力上限
|
||||
type Effect1517 struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1517) Skill_Use() bool {
|
||||
if len(e.Args()) == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp > 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1517, int(e.Args()[0].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1517Sub struct{ node.EffectNode }
|
||||
|
||||
func (e *Effect1517Sub) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(1)
|
||||
e.CanStack(false)
|
||||
}
|
||||
|
||||
func (e *Effect1517Sub) SwitchIn(in *input.Input) bool {
|
||||
if in != e.Ctx().Opp || len(e.Args()) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, e.Args()[0])
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1513, &Effect1513{})
|
||||
input.InitEffect(input.EffectType.Skill, 1514, &Effect1514{})
|
||||
input.InitEffect(input.EffectType.Sub, 1514, &Effect1514PendingSub{})
|
||||
input.InitEffect(input.EffectType.Sub, 15141, &Effect1514BahuangSub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1515, &Effect1515{})
|
||||
input.InitEffect(input.EffectType.Skill, 1516, &Effect1516{})
|
||||
input.InitEffect(input.EffectType.Sub, 1516, &Effect1516Sub{})
|
||||
input.InitEffect(input.EffectType.Skill, 1517, &Effect1517{})
|
||||
input.InitEffect(input.EffectType.Sub, 1517, &Effect1517Sub{})
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 556: 命中后使自身体力降为1
|
||||
type Effect556 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect556) OnSkill() bool {
|
||||
|
||||
// 使自身体力降为1,但不能低于1
|
||||
currentHP := e.Ctx().Our.CurrentPet.Info.Hp
|
||||
if currentHP > 1 {
|
||||
// 计算需要减少的体力值,使最终体力为1
|
||||
damageAmount := int64(currentHP - 1)
|
||||
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(damageAmount),
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, damageZone)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 556, &Effect556{})
|
||||
}
|
||||
@@ -157,7 +157,7 @@ type Effect604 struct {
|
||||
|
||||
func (e *Effect604) SkillHit() bool {
|
||||
randomPower := grand.N(int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
|
||||
e.Ctx().SkillEntity.XML.Power = randomPower + int(e.GetADD(alpacadecimal.Zero, e.Args()[2], e.Args()[3]).IntPart())
|
||||
e.Ctx().SkillEntity.XML.Power = randomPower + int(e.GetStackOnlyADD(e.Args()[2], e.Args()[3]).IntPart())
|
||||
return e.AddLvelEffect.SkillHit()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
// Effect 615: {0}回合内使用技能恢复{1}点体力,体力低于1/{2}时恢复至满
|
||||
@@ -57,74 +55,6 @@ func (e *Effect616) ComparePre(fattack, sattack *action.SelectSkillAction) bool
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 617: 消耗自身所有体力给对手造成{0}-{1}点伤害,若造成伤害大于对手体力,则对手必定留1点血
|
||||
type Effect617 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect617) Skill_Use() bool {
|
||||
if len(e.Args()) < 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetMaxHP(),
|
||||
})
|
||||
|
||||
minDamage := int(e.Args()[0].IntPart())
|
||||
maxDamage := int(e.Args()[1].IntPart())
|
||||
if maxDamage < minDamage {
|
||||
minDamage, maxDamage = maxDamage, minDamage
|
||||
}
|
||||
|
||||
randomDamage := minDamage
|
||||
if maxDamage > minDamage {
|
||||
randomDamage = grand.N(minDamage, maxDamage)
|
||||
}
|
||||
|
||||
remainHP := e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))
|
||||
if remainHP.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
damage := alpacadecimal.Min(alpacadecimal.NewFromInt(int64(randomDamage)), remainHP)
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damage,
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 618: 消耗自身所有体力,使下一只出战精灵{0}回合内每回合恢复{1}点体力
|
||||
type Effect618 struct {
|
||||
SelfKill
|
||||
}
|
||||
|
||||
func (e *Effect618) SwitchIn(in *input.Input) bool {
|
||||
if !e.can || in != e.Ctx().Our {
|
||||
return true
|
||||
}
|
||||
|
||||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 618, e.SideEffectArgs...)
|
||||
if effect != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||||
}
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect618Sub struct {
|
||||
RoundEffectArg0Base
|
||||
}
|
||||
|
||||
func (e *Effect618Sub) TurnEnd() {
|
||||
if len(e.Args()) > 1 && e.Ctx().Our.CurrentPet.Info.Hp > 0 {
|
||||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Args()[1])
|
||||
}
|
||||
e.EffectNode.TurnEnd()
|
||||
}
|
||||
|
||||
// Effect 619: 下{0}回合令对手所有技能先制-{1}
|
||||
type Effect619 struct {
|
||||
node.EffectNode
|
||||
@@ -161,9 +91,6 @@ func (e *Effect619Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bo
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 615, &Effect615{})
|
||||
input.InitEffect(input.EffectType.Skill, 616, &Effect616{})
|
||||
input.InitEffect(input.EffectType.Skill, 617, &Effect617{})
|
||||
input.InitEffect(input.EffectType.Skill, 618, &Effect618{})
|
||||
input.InitEffect(input.EffectType.Sub, 618, &Effect618Sub{})
|
||||
input.InitEffect(input.EffectType.Skill, 619, &Effect619{})
|
||||
input.InitEffect(input.EffectType.Sub, 619, &Effect619Sub{})
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 479: 损失自身{0}点体力,给对手造成{1}点固定伤害,若自身体力不足{2}则剩下{3}点体力
|
||||
type Effect479 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect479) OnSkill() bool {
|
||||
selfDamage := alpacadecimal.NewFromInt(int64(e.Args()[0].IntPart()))
|
||||
opponentDamage := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
|
||||
|
||||
// 检查自身体力是否低于200
|
||||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||||
minHp := alpacadecimal.NewFromInt(200)
|
||||
|
||||
if currentHp.Cmp(minHp) < 0 {
|
||||
// 如果自身体力不足200,保留1点体力
|
||||
damageToTake := currentHp.Sub(alpacadecimal.NewFromInt(1))
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damageToTake,
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, damageZone)
|
||||
} else {
|
||||
// 损失n点体力
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: selfDamage,
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, damageZone)
|
||||
}
|
||||
|
||||
// 给对手造成m点固定伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: opponentDamage,
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 479, &Effect479{})
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 72: 若没有命中对手则自己失去全部体力
|
||||
type Effect72 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
ret := &Effect72{}
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 72, ret)
|
||||
|
||||
}
|
||||
|
||||
// SkillHit 命中之后
|
||||
func (e *Effect72) SkillHit() bool {
|
||||
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if e.Ctx().AttackTime != 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.True,
|
||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp)),
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 79: 损失1/2的体力,提升自身的能力
|
||||
type Effect79 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 79, &Effect79{})
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
// 特攻+2速度+1命中+1,
|
||||
func (e *Effect79) OnSkill() bool {
|
||||
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 2, 2)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 5, 1)
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetHP().Div(alpacadecimal.NewFromInt(2)),
|
||||
})
|
||||
return true
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// Effect 80: 损失1/2的体力,给予对手同等的伤害
|
||||
type Effect80 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 80, &Effect80{})
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect80) Skill_Use() bool {
|
||||
|
||||
att := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(2))
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: att,
|
||||
})
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: att,
|
||||
})
|
||||
return true
|
||||
}
|
||||
@@ -38,9 +38,23 @@ func (e *AddLvelEffect) SkillHit() bool {
|
||||
}
|
||||
|
||||
func (e *AddLvelEffect) GetADD(base, add, max alpacadecimal.Decimal) alpacadecimal.Decimal {
|
||||
count := e.UseSkillCount - 1
|
||||
if count < 0 {
|
||||
count = 0
|
||||
}
|
||||
|
||||
value := base
|
||||
if count > 0 {
|
||||
value = value.Add(add.Mul(alpacadecimal.NewFromInt(count)))
|
||||
}
|
||||
return alpacadecimal.Min(value, max)
|
||||
}
|
||||
|
||||
func (e *AddLvelEffect) GetStackOnlyADD(add, max alpacadecimal.Decimal) alpacadecimal.Decimal {
|
||||
if e.UseSkillCount <= 0 {
|
||||
return alpacadecimal.Zero
|
||||
}
|
||||
return alpacadecimal.Min(add.Mul(alpacadecimal.NewFromInt(e.UseSkillCount)), max)
|
||||
|
||||
}
|
||||
func init() {
|
||||
|
||||
@@ -54,10 +68,15 @@ type Effect9 struct {
|
||||
}
|
||||
|
||||
func (e *Effect9) SkillHit() bool {
|
||||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
if (e.Skillid != 0 && e.Ctx().SkillEntity.XML.ID != e.Skillid) || e.Ctx().SkillEntity.AttackTime == 0 {
|
||||
return e.AddLvelEffect.SkillHit()
|
||||
}
|
||||
|
||||
e.Ctx().SkillEntity.XML.Power += int(e.GetADD(alpacadecimal.Zero, e.Args()[0], e.Args()[1]).IntPart())
|
||||
|
||||
return true
|
||||
e.Ctx().SkillEntity.XML.Power += int(e.GetStackOnlyADD(e.Args()[0], e.Args()[1]).IntPart())
|
||||
return e.AddLvelEffect.SkillHit()
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 484, &Effect484{})
|
||||
@@ -170,7 +189,7 @@ func (e *Effect441) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
e.Ctx().SkillEntity.XML.CritRate += int(e.GetADD(alpacadecimal.Zero, e.Args()[2], e.Args()[3]).IntPart())
|
||||
e.Ctx().SkillEntity.XML.CritRate += int(e.GetStackOnlyADD(e.Args()[2], e.Args()[3]).IntPart())
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -16,12 +16,11 @@ type SelfKill struct {
|
||||
}
|
||||
|
||||
func (e *SelfKill) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
//e.CanStack(-1)//后续的不会顶掉这个效果
|
||||
// e.CanStack(-1)//后续的不会顶掉这个效果
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1) //次数类,无限回合
|
||||
|
||||
e.Duration(-1) // 次数类,无限回合
|
||||
}
|
||||
|
||||
func (e *SelfKill) OnSkill() bool {
|
||||
if e.can {
|
||||
return true
|
||||
@@ -47,9 +46,7 @@ type Effect59 struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 59, &Effect59{})
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect59) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||||
@@ -59,15 +56,6 @@ func (e *Effect59) TurnStart(fattack *action.SelectSkillAction, sattack *action.
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1)
|
||||
e.Alive(false)
|
||||
return
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 71, &Effect71{
|
||||
count: 2,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Effect 71: 消耗自身全部体力,己方下2次攻击技能必定打出致命一击
|
||||
@@ -76,11 +64,14 @@ type Effect71 struct {
|
||||
count int
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 71, &Effect71{count: 2})
|
||||
}
|
||||
|
||||
func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
//fmt.Println(e.Ctx().SkillEntity)
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
@@ -92,14 +83,166 @@ func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
e.count--
|
||||
if e.count <= 0 {
|
||||
e.Alive(false)
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 72: 若没有命中对手则自己失去全部体力
|
||||
type Effect72 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 72, &Effect72{})
|
||||
}
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 144, &Effect144{})
|
||||
// SkillHit 命中之后
|
||||
func (e *Effect72) SkillHit() bool {
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().AttackTime != 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.True,
|
||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp)),
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 79: 损失1/2的体力,提升自身的能力
|
||||
type Effect79 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 79, &Effect79{})
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
// 特攻+2速度+1命中+1
|
||||
func (e *Effect79) OnSkill() bool {
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 2, 2)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 5, 1)
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetHP().Div(alpacadecimal.NewFromInt(2)),
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 80: 损失1/2的体力,给予对手同等的伤害
|
||||
type Effect80 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 80, &Effect80{})
|
||||
}
|
||||
|
||||
func (e *Effect80) Skill_Use() bool {
|
||||
att := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(2))
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: att,
|
||||
})
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: att,
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 112: 牺牲全部体力给对手造成250~300点伤害,造成致命伤害时,对手剩下1点体力
|
||||
type Effect112 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect112) Skill_Use() bool {
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||||
})
|
||||
minDamage := int64(250)
|
||||
maxDamage := int64(300)
|
||||
n := int64(grand.N(int(minDamage), int(maxDamage)))
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.Min(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 137: 损失一半当前体力值,自身攻击和速度提升2个等级
|
||||
type Effect137 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 137, &Effect137{})
|
||||
}
|
||||
|
||||
func (e *Effect137) OnSkill() bool {
|
||||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||||
halfHp := currentHp.Div(alpacadecimal.NewFromInt(2))
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: halfHp,
|
||||
})
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 2)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, 0, 2)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 142: 损失1/{0}的体力值,下回合能较快出手
|
||||
type Effect142 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 142, &Effect142{})
|
||||
}
|
||||
|
||||
func (e *Effect142) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||||
if fattack == nil {
|
||||
return true
|
||||
}
|
||||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
if sattack.SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
sattack.SkillEntity.XML.Priority += 1
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect142) OnSkill() bool {
|
||||
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||||
damageAmount := maxHp.Div(e.Args()[0])
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damageAmount,
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 144: 消耗自己所有体力,使下一个出战的精灵{0}回合免疫异常状态
|
||||
@@ -108,9 +251,12 @@ type Effect144 struct {
|
||||
count int
|
||||
}
|
||||
|
||||
func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 144, &Effect144{})
|
||||
}
|
||||
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
// 魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
@@ -118,7 +264,7 @@ func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
if int(e.Input.FightC.GetOverInfo().Round) >= e.count+e.SideEffectArgs[0] {
|
||||
e.Alive(false)
|
||||
}
|
||||
if e.count == 0 { //记录开始回合
|
||||
if e.count == 0 {
|
||||
e.count = int(e.Input.FightC.GetOverInfo().Round)
|
||||
}
|
||||
|
||||
@@ -137,6 +283,10 @@ type Effect435 struct {
|
||||
SelfKill
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
|
||||
}
|
||||
|
||||
func (e *Effect435) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
@@ -144,30 +294,25 @@ func (e *Effect435) ComparePre(fattack *action.SelectSkillAction, sattack *actio
|
||||
if fattack == nil {
|
||||
return true
|
||||
}
|
||||
//先手是自己
|
||||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
if sattack.SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
//对调
|
||||
|
||||
sattack.SkillEntity.XML.Priority += 7
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
func (e *Effect435) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
|
||||
func (e *Effect435) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
//fmt.Println(e.Ctx().SkillEntity)
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
@@ -177,43 +322,74 @@ func (e *Effect435) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
e.Ctx().SkillEntity.XML.MustHit = 1
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
|
||||
|
||||
}
|
||||
|
||||
// Effect 112: 牺牲全部体力给对手造成250~300点伤害,造成致命伤害时,对手剩下1点体力
|
||||
type Effect112 struct {
|
||||
// Effect 479: 损失自身{0}点体力,给对手造成{1}点固定伤害,若自身体力不足{2}则剩下{3}点体力
|
||||
type Effect479 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 479, &Effect479{})
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect112) Skill_Use() bool {
|
||||
func (e *Effect479) OnSkill() bool {
|
||||
selfDamage := alpacadecimal.NewFromInt(int64(e.Args()[0].IntPart()))
|
||||
opponentDamage := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
|
||||
|
||||
currentHp := e.Ctx().Our.CurrentPet.GetHP()
|
||||
minHp := alpacadecimal.NewFromInt(200)
|
||||
|
||||
if currentHp.Cmp(minHp) < 0 {
|
||||
damageToTake := currentHp.Sub(alpacadecimal.NewFromInt(1))
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damageToTake,
|
||||
})
|
||||
} else {
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: selfDamage,
|
||||
})
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||||
})
|
||||
n := int64(grand.N(250, 300))
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.Min(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
|
||||
Damage: opponentDamage,
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 556: 命中后使自身体力降为1
|
||||
type Effect556 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 556, &Effect556{})
|
||||
}
|
||||
|
||||
func (e *Effect556) OnSkill() bool {
|
||||
currentHP := e.Ctx().Our.CurrentPet.Info.Hp
|
||||
if currentHP > 1 {
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(int64(currentHP - 1)),
|
||||
})
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 574: 消耗自身全部体力,令己方下次使用的技能必定先手、必定命中,下次命中的攻击技能必定打出致命一击
|
||||
type Effect574 struct {
|
||||
SelfKill
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 574, &Effect574{})
|
||||
}
|
||||
|
||||
func (e *Effect574) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
@@ -221,31 +397,25 @@ func (e *Effect574) ComparePre(fattack *action.SelectSkillAction, sattack *actio
|
||||
if fattack == nil {
|
||||
return true
|
||||
}
|
||||
//先手是自己
|
||||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
if sattack == nil {
|
||||
return true
|
||||
}
|
||||
if sattack.SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
//对调
|
||||
sattack.SkillEntity.XML.Priority += 7
|
||||
|
||||
sattack.SkillEntity.XML.Priority += 7
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
func (e *Effect574) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
|
||||
func (e *Effect574) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
//fmt.Println(e.Ctx().SkillEntity)
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
@@ -257,7 +427,121 @@ func (e *Effect574) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 574, &Effect574{})
|
||||
|
||||
// Effect 617: 消耗自身所有体力给对手造成{0}-{1}点伤害,若造成伤害大于对手体力,则对手必定留1点血
|
||||
type Effect617 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 617, &Effect617{})
|
||||
}
|
||||
|
||||
func (e *Effect617) Skill_Use() bool {
|
||||
if len(e.Args()) < 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetMaxHP(),
|
||||
})
|
||||
|
||||
minDamage := int(e.Args()[0].IntPart())
|
||||
maxDamage := int(e.Args()[1].IntPart())
|
||||
if maxDamage < minDamage {
|
||||
minDamage, maxDamage = maxDamage, minDamage
|
||||
}
|
||||
|
||||
randomDamage := minDamage
|
||||
if maxDamage > minDamage {
|
||||
randomDamage = grand.N(minDamage, maxDamage)
|
||||
}
|
||||
|
||||
remainHP := e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))
|
||||
if remainHP.Cmp(alpacadecimal.Zero) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
damage := alpacadecimal.Min(alpacadecimal.NewFromInt(int64(randomDamage)), remainHP)
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: damage,
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
// Effect 618: 消耗自身所有体力,使下一只出战精灵{0}回合内每回合恢复{1}点体力
|
||||
type Effect618 struct {
|
||||
SelfKill
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 618, &Effect618{})
|
||||
input.InitEffect(input.EffectType.Sub, 618, &Effect618Sub{})
|
||||
}
|
||||
|
||||
func (e *Effect618) SwitchIn(in *input.Input) bool {
|
||||
if !e.can || in != e.Ctx().Our {
|
||||
return true
|
||||
}
|
||||
|
||||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 618, e.SideEffectArgs...)
|
||||
if effect != nil {
|
||||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||||
}
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect618Sub struct {
|
||||
RoundEffectArg0Base
|
||||
}
|
||||
|
||||
func (e *Effect618Sub) TurnEnd() {
|
||||
if len(e.Args()) > 1 && e.Ctx().Our.CurrentPet.Info.Hp > 0 {
|
||||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Args()[1])
|
||||
}
|
||||
e.EffectNode.TurnEnd()
|
||||
}
|
||||
|
||||
// Effect 1380: 牺牲自身全部体力,使对手全属性-{0}且{1}回合内先制-{2}
|
||||
type Effect1380 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1380, &Effect1380{})
|
||||
input.InitEffect(input.EffectType.Sub, 1380, &Effect1380Sub{})
|
||||
}
|
||||
|
||||
func (e *Effect1380) Skill_Use() bool {
|
||||
if len(e.Args()) < 3 {
|
||||
return true
|
||||
}
|
||||
|
||||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
|
||||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1380, int(e.Args()[1].IntPart()), int(e.Args()[2].IntPart()))
|
||||
if sub != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||||
}
|
||||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Our.CurrentPet.GetHP(),
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
type Effect1380Sub struct {
|
||||
RoundEffectArg0Base
|
||||
}
|
||||
|
||||
func (e *Effect1380Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||||
if current == nil || current.SkillEntity == nil || len(e.Args()) < 2 {
|
||||
return true
|
||||
}
|
||||
|
||||
current.SkillEntity.XML.Priority -= int(e.Args()[1].IntPart())
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package effect
|
||||
import (
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
type RoundEffectArg0Base struct {
|
||||
@@ -13,6 +15,17 @@ func (e *RoundEffectArg0Base) SetArgs(t *input.Input, a ...int) {
|
||||
setArgsWithDuration0(&e.EffectNode, t, a...)
|
||||
}
|
||||
|
||||
type RandomDurationArg01Base struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *RandomDurationArg01Base) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
if len(a) > 1 {
|
||||
e.Duration(grand.N(a[0], a[1]))
|
||||
}
|
||||
}
|
||||
|
||||
type RoundEffectSideArg0Base struct {
|
||||
node.EffectNode
|
||||
}
|
||||
@@ -37,6 +50,18 @@ func (e *FixedDurationNeg1Base) SetArgs(t *input.Input, a ...int) {
|
||||
setArgsWithFixedDuration(&e.EffectNode, t, -1, a...)
|
||||
}
|
||||
|
||||
type FixedDurationNeg1Arg0CountBase struct {
|
||||
node.EffectNode
|
||||
remaining int
|
||||
}
|
||||
|
||||
func (e *FixedDurationNeg1Arg0CountBase) SetArgs(t *input.Input, a ...int) {
|
||||
setArgsWithFixedDuration(&e.EffectNode, t, -1, a...)
|
||||
if len(a) > 0 {
|
||||
e.remaining = a[0]
|
||||
}
|
||||
}
|
||||
|
||||
type FixedDuration2Base struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/user"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
@@ -35,6 +36,7 @@ type FightC struct {
|
||||
actionNotify chan struct{}
|
||||
acceptActions bool
|
||||
pendingActions []action.BattleActionI // 待处理动作队列,同一玩家最多保留两段动作
|
||||
actionRound atomic.Uint32
|
||||
|
||||
quit chan struct{}
|
||||
over chan struct{}
|
||||
|
||||
Reference in New Issue
Block a user