解决冲突

This commit is contained in:
zhl 2020-12-03 12:20:45 +08:00
commit 12cfa01e29
12 changed files with 234 additions and 133 deletions

View File

@ -4,21 +4,21 @@ import {Cfg} from "../../common/DataParser";
export class EffectCardCfg implements Cfg{
public id: number;
public maxCount: number;
public typeId: number;
public eff1Id: number;
public eff2Id: number;
public eff3Id: number;
public eff4Id: number;
public eff5Id: number;
public type_id: number;
public eff1_id: number;
public eff2_id: number;
public eff3_id: number;
public eff4_id: number;
public eff5_id: number;
public decode(data: any) {
this.id = data.id;
this.typeId = data.type_id;
this.eff1Id = data.eff1_id;
this.eff2Id = data.eff2_id;
this.eff3Id = data.eff3_id;
this.eff4Id = data.eff4_id;
this.eff5Id = data.eff5_id;
this.type_id = data.type_id;
this.eff1_id = data.eff1_id;
this.eff2_id = data.eff2_id;
this.eff3_id = data.eff3_id;
this.eff4_id = data.eff4_id;
this.eff5_id = data.eff5_id;
this.maxCount = 20;
}
}

View File

@ -2,12 +2,12 @@ import {Cfg} from "../../common/DataParser";
export class HeroCfg implements Cfg{
public id: number;
public unitId: number;
public exSkill: number;
public unit_id: number;
public ex_skill: number;
public decode(data: any) {
this.id = data.id;
this.unitId = data.unit_id;
this.exSkill = data.ex_skill;
this.unit_id = data.unit_id;
this.ex_skill = data.ex_skill;
}
}

View File

@ -3,41 +3,41 @@ import {Cfg} from "../../common/DataParser";
export class SkillCfg implements Cfg{
public id: number;
public skillType: number;
public triggerType: number;
public condType: number;
public condV1: number;
public condV2: number;
public effectType: number;
public skill_type: number;
public tigger_type: number;
public cond_type: number;
public cond_v1: number;
public cond_v2: number;
public effect_type: number;
public friendly: number;
public target: number;
public range: number;
public effV1: number;
public effV2: number;
public effV3: number;
public effV4: number;
public unitId: number;
public unitCount: number;
public subSkillId: number;
public subSkillCount: number;
public eff_v1: number;
public eff_v2: number;
public eff_v3: number;
public eff_v4: number;
public unit_id: number;
public unit_count: number;
public subskill_id: number;
public subskill_count: number;
public decode(data: any) {
this.id = data.id;
this.skillType = data.skill_type;
this.triggerType = data.tigger_type;
this.condType = data.cond_type;
this.condV1 = data.cond_v1;
this.condV2 = data.cond_v2;
this.effectType = data.effect_type;
this.skill_type = data.skill_type;
this.tigger_type = data.tigger_type;
this.cond_type = data.cond_type;
this.cond_v1 = data.cond_v1;
this.cond_v2 = data.cond_v2;
this.effect_type = data.effect_type;
this.friendly = data.friendly;
this.target = data.target;
this.range = data.range;
this.effV1 = data.eff_v1;
this.effV2 = data.eff_v2;
this.effV3 = data.eff_v3;
this.effV4 = data.eff_v4;
this.unitId = data.unit_id;
this.unitCount = data.unit_count;
this.subSkillId = data.subskill_id;
this.subSkillCount = data.subskill_count;
this.eff_v1 = data.eff_v1;
this.eff_v2 = data.eff_v2;
this.eff_v3 = data.eff_v3;
this.eff_v4 = data.eff_v4;
this.unit_id = data.unit_id;
this.unit_count = data.unit_count;
this.subskill_id = data.subskill_id;
this.subskill_count = data.subskill_count;
}
}

View File

@ -3,30 +3,30 @@ import {Cfg} from "../../common/DataParser";
export class UnitCfg implements Cfg{
public id: number;
public typeId: number;
public heroHp: number;
public raceId: number;
public jobId: number;
public powerType: number;
public powerValue: number;
public effType: number;
public effValue: number;
public skill1Id: number;
public skill2Id: number;
public skill3Id: number;
public type_id: number;
public hero_hp: number;
public raceid: number;
public job_id: number;
public power_type: number;
public power_value: number;
public eff_type: number;
public eff_value: number;
public skill1_id: number;
public skill2_id: number;
public skill3_id: number;
public decode(data: any) {
this.id = data.id;
this.typeId = data.type_id;
this.heroHp = data.hero_hp;
this.raceId = data.raceid;
this.jobId = data.job_id;
this.powerType = data.power_type;
this.powerValue = data.power_value;
this.effType = data.eff_type;
this.effValue = data.eff_value;
this.skill1Id = data.skill1_id;
this.skill2Id = data.skill2_id;
this.skill3Id = data.skill3_id;
this.type_id = data.type_id;
this.hero_hp = data.hero_hp;
this.raceid = data.raceid;
this.job_id = data.job_id;
this.power_type = data.power_type;
this.power_value = data.power_value;
this.eff_type = data.eff_type;
this.eff_value = data.eff_value;
this.skill1_id = data.skill1_id;
this.skill2_id = data.skill2_id;
this.skill3_id = data.skill3_id;
}
}

View File

@ -6,7 +6,8 @@ import {SkillCfg} from "../cfg/parsers/SkillCfg";
import {SystemCardCfg} from "../cfg/parsers/SystemCardCfg";
import {UnitCfg} from "../cfg/parsers/UnitCfg";
import {BaseConst} from "../constants/BaseConst";
import SkillMan from "../rooms/logic/skill/SkillMan";
let SkillMan = require('../rooms/logic/skill/SkillMan');
export function initData() {
const rP = DataParser.regCommonParser.bind(DataParser);

View File

@ -8,42 +8,33 @@ import { Pet } from "rooms/schema/Pet";
export class BattleHandler {
private _cs: CardGameState;
private _players: PlayerHandler[];
private _players: Map<Player, PlayerHandler> = new Map();
public init(cs: CardGameState){
this._cs = cs;
this._players = [];
};
public addPlayer(aplayer: Player){
let ph = new PlayerHandler();
ph.init(aplayer, this);
this._players.push(ph);
this._players.set(aplayer, ph);
};
public delPlayer(aplayer: Player){
let idx = this._players.findIndex((item: PlayerHandler)=>{
return item._player == aplayer;
})
this._players.splice(idx, 1);
this._players.delete(aplayer);
};
public getPlayer(aplayer: Player){
return this._players.find((item: PlayerHandler)=>{
return item._player == aplayer;
})
return this._players.get(aplayer);
};
public useCard(obj:
{srcplayer: Player, card: Card, dbeff_cnt: number, dbpt_cnt: number, dstplayer: Player, dstpet: Pet})
{srcplayer: Player, card: Card, cardpoint: number, eff_cnt: number, dstplayer: Player, dstpet: Pet})
{
if(!obj || obj.card){
return false;
}
let cfg = CfgMan.findEffCardCfg(obj.card.id);
if(!cfg){
return false;
}
let ph = this.getPlayer(obj.srcplayer);
@ -51,10 +42,80 @@ export class BattleHandler {
return false;
}
if(cfg.typeId == EffectCardType.NPC){
}else if(cfg.typeId == EffectCardType.MAGIC){
}
ph.useCard(obj);
};
}
/**
*
* @param obj
*/
public useSkill(obj:{
srcplayer: Player, skillid: number, dstplayer: Player, dstpet: Pet
}){
};
/**
* /
* @param aplayer : 玩家
* @param fromplayer
*/
public onCardLinkReady(aplayer: Player, fromplayer?: Player){
};
/**
* /
* @param aplayer
* @param linkcards
*/
public onCardLinkOver(aplayer: Player, linkcards: Card[]){
};
/**
* 使
* @param obj 使
*/
public onUseCardEnd(obj:
{srcplayer: Player, card: Card, cardpoint: number, eff_cnt: number, dstplayer: Player, dstpet: Pet}
){
};
/**
*
* @param aplayer
* @param fromplayer : 谁使玩家弃牌的
* @param dropcards : 弃掉的牌组
*/
public onCardDroped(aplayer: Player, dropcards: Card[], fromplayer?: Player){
};
/**
*
* @param aplayer
* @param fromplayer : 谁使玩家获得牌的
* @param dropcards : 获得的牌组
*/
public onCardGetted(aplayer: Player, getcards: Card[], fromplayer?: Player){
};
/**
*
* @param aplayer
*/
public onPlayerRoundStart(aplayer: Player){
}
/**
*
* @param aplayer
*/
public onPlayerRoundEnd(aplayer: Player){
}
}

View File

@ -1,4 +1,5 @@
import { Pet } from "../../schema/Pet";
import CfgMan from "../CfgMan";
import {Skill} from "../skill/Skill";
import { PlayerHandler } from "./PlayerHandler";
@ -6,6 +7,12 @@ import { PlayerHandler } from "./PlayerHandler";
export class PetHandler {
private _pet: Pet;
private _owner: PlayerHandler;
_id: number;
_cfg: any;
_exskills: number[];
_ap: number;
public init(apet: Pet, owner: PlayerHandler){
this._pet = apet;
this._owner = owner;
@ -16,4 +23,18 @@ export class PetHandler {
public addAttr(attrstr: string, value: number, sender: Skill){
};
public setParam(id: number, ap: number, effcnt: number, exskillid: number[]){
this._id = id;
this._cfg = CfgMan.findUnitCfg(id);
this._exskills.length = 0;
exskillid.forEach((skillid: number)=>{
if(skillid > 0){
this._exskills.push(skillid);
}
});
}
}

View File

@ -5,12 +5,16 @@ import { BattleHandler } from "./BattleHandler";
import CfgMan from "../CfgMan";
import { Card } from "rooms/schema/Card";
import { Pet } from "rooms/schema/Pet";
import { EffectCardType } from "../skill/SkillConst";
import { UnitCfg } from "cfg/parsers/UnitCfg";
export class PlayerHandler {
public _player: Player;
public _playercfg: HeroCfg;
public _unitcfg: UnitCfg;
public _pets: PetHandler[];
private _owner: BattleHandler;
@ -19,6 +23,7 @@ export class PlayerHandler {
this._owner = owner;
this._player = aplayer;
this._playercfg = CfgMan.findPlayerCfg(this._player.heroId);
this._unitcfg = this._playercfg && CfgMan.findUnitCfg(this._playercfg.unit_id);
};
public getCurrCardCount(){
@ -39,7 +44,7 @@ export class PlayerHandler {
break;
}
}
if(res){
pr = new PetHandler;
pr.init(res, this);
@ -50,9 +55,33 @@ export class PlayerHandler {
};
public useCard(obj:
{card: Card, dbeff_cnt: number, dbpt_cnt: number, dstplayer: Player, dstpet: Pet})
{card: Card, cardpoint: number, eff_cnt: number, dstplayer: Player, dstpet: Pet})
{
let cfg = CfgMan.findEffCardCfg(obj.card.id);
if(!cfg){
return false;
}
if(cfg.typeId == EffectCardType.NPC){
let pet = this.newPet();
if(!pet){
return false;
}
pet.setParam(cfg.eff1Id, obj.cardpoint, obj.eff_cnt, [cfg.eff2Id, cfg.eff3Id, cfg.eff4Id, cfg.eff5Id]);
}else if(cfg.typeId == EffectCardType.MAGIC){
}
};
public useSkill(obj:{
skillid: number, dstplayer: Player, dstpet: Pet})
{
};
public addSkill(skillid: number){
}
}
}

View File

@ -60,4 +60,4 @@ export class Condition {
}
};
module.exports = Condition;
// module.exports = Condition;

View File

@ -1,11 +1,7 @@
import { PetHandler } from "../Handler/PetHandler";
import { TriggerType } from "./SkillConst";
import TriggerManager from "./TriggerMan";
let con = require('constant');
let SK_TYPE = con.SKILL_TYPE;
let TG_TYPE = con.TRIGGER_TYPE;
export class Skill {
_currCount: number;
_roundCount: number;
@ -71,14 +67,14 @@ export class Skill {
this._id = skillid;
this._data = skilldata;
this._type = skilldata.effec_id;
this._show_effect = this.initSkillShowEffectData();
// this._show_effect = this.initSkillShowEffectData();
// todo: 根据bufftype处理paramlst
this._params = TriggerManager.handleEffectParam(this._type, skilldata.effec_valu);
this._tgctrl = TriggerManager.addSkillTrigger(this._id, skilldata.triggerType, skilldata.condType, skilldata.condition_valu);
if (this._params.length > 4) {
this._maxvalue = this._params[4];
}
// if (this._params.length > 4) {
// this._maxvalue = this._params[4];
// }
this._man = manager;
};
@ -136,19 +132,9 @@ export class Skill {
return this._data && (this._data.is_sp == 1);
};
// 是否是位移技能
isMapSkill() {
return false; //this._type == SK_TYPE.DASH_ATK || this._type == SK_TYPE.BACK_ATK;
};
// 是否是获得即起效技能
isIMMSkill() {
return this._data && (this._data.trigger_id == TG_TYPE.IMM);
};
// 是否是抢先攻击技能
isDefFirstSkill() {
return this._data && (this._type == SK_TYPE.ATK_FIRST);
return this._data && (this._data.trigger_id == TriggerType.NO_COND);
};
canComposition() {
@ -176,7 +162,7 @@ export class Skill {
};
checkTrigger(tg_type: any, tg_value: any, tg_target: any, cb: any) {
if (tg_type == TG_TYPE.MYGROUPROUND_START) {
if (tg_type == TriggerType.ROUND_START_MYSELF) {
this._roundCount++;
if (this._start) {
this._startround++;
@ -519,4 +505,4 @@ export class Skill {
obj._maxvalue = this._maxvalue;
return obj;
};
};
};

View File

@ -38,6 +38,8 @@ export const enum TriggerType
ROUND_END_MYSELF = 5,
CARD_GETTED = 6,
ROUND_START_MYSELF = 6,
};
export const enum SkillType{

View File

@ -8,32 +8,25 @@
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
import { Skill } from "./Skill";
import {SkillCfg} from "../../../cfg/parsers/SkillCfg";
let SkillManager = {
_skillmap: {},
_tilemap: {},
let SkillMan = {
_skillmap: new Map(),
onSkillTrigger(skill, param, bok) {
_skillcb: function(p1:any, p2:any, p3:any, p4:any){},
onSkillTrigger(skill:Skill, param: any, bok: boolean) {
this._skillcb && this._skillcb(skill, param, bok, skill._owner);
},
getSkillMaxLevel(id) {
let obj = this._skillmap[id];
if (obj) {
return obj._data.max_lv;
} else {
return null;
}
},
addSkill(id, data) {
addSkill(id: number, data: SkillCfg) {
let obj = new Skill();
obj.init(id, data, this);
this._skillmap[id] = obj;
this._skillmap.set(id, obj);
},
getSkill(id) {
let obj = this._skillmap[id];
getSkill(id: number) {
let obj = this._skillmap.get(id);
if (obj) {
return obj.clone();
// return comutils.cloneFull(obj);
@ -41,9 +34,17 @@ let SkillManager = {
return null;
},
setSkillCallback(cb) {
setSkillCallback(cb: any) {
this._skillcb = cb;
},
loadData(skills: Map<number, SkillCfg>){
skills.forEach((value, key)=>{
if(key > 0){
this.addSkill(key, value);
}
});
}
};
export default SkillManager;
module.exports = SkillMan;