import {composeObj,baseObj,objType, propBase, valueObj} from './baseObject' import {Propbuff,buffIF,propType, PropUnlock, PropLeaveUp, PropCatch, PropSignIn, IPSignIn} from './propObject' import dataManager from './DataManager' import gameFun from './gameFun' import {excelJson,saleCfg,levelCfg,unlockCfg,objCfg, funcExpression, buffCfg, buffType, IDDef} from './excelDefine' import DataManager from './DataManager' import gameCfg from '../../config/gameCfg' export interface catchData{ mapCatched:Map,//总共捕获的鱼id,鱼数量 vecNewCatched:Array,//新捕获 allFee:number,//出售费用 } //游戏对象,包含一系列资产 export default class GameInfo extends composeObj{ m_gameFun:gameFun = new gameFun()//依赖游戏函数 //构造 constructor(gameId:number){ super(gameId) this.addProp(new PropSignIn()) } m_mapMeansList:Map=new Map()//快捷查询物品列表 //签到属性 //获取资产道具 findMeans(id:number){ return this.m_mapMeansList.get(id); } //获取单位时间增加的金币门票 admissionFee(){ let buffList = this.getPropDeep(propType.buff) let coinAddBase = gameCfg.startParkFee let addProb = 1 for(let idx=0;idx = new Map() if(exData) { let arrList = exData._unlockCondition for (let idx=0;idx = new Map() if(!data)return mapDesp let findProp = data.getPropByType(propType.level) if(!findProp)return mapDesp let lvObj = findProp as PropLeaveUp let exData = dataManager.ins().getLevelCfgByIdLv(id,lvObj.getLevel()); if(exData) { let arrList = exData._growupCondition let able = true for (let idx=0;idx0 && (bUnlock==true)) return false; let exData = dataManager.ins().getLevelCfgByIdLv(id,curLv); let bUpAble = this.isUpLevelObjAble(id) if(curLv>0) bUpAble = true if(exData) { let arrList = exData._growupResult let able = true for (let idx=0;idxjsonData._idFun;//解锁条件id if(idFun==funcExpression.addBuffCoinNum || idFun==funcExpression.addBuffCoinPer) { let num = 0 if (jsonData._param[0] instanceof Object)//excelJson,表达式 num = this.m_gameFun.doExpressDecode(this,jsonData._param[0],id) as number else num = jsonData._param[0] let bufftp = idFun ==funcExpression.addBuffCoinNum ? buffType.base:buffType.ratio if(buffProp) buffProp.setBuff(bufftp,num) } } } return true; } //捕鱼操作,钓鱼对象中找,time表示次数,在线一分钟一次,perOwn:已钓比例,perUnOwn:未钓比例 doCatchFish(time:number,perOwn:number,perUnOwn:number):catchData{ let vecAbleFishId = Array()//可钓列表 let vecCatched = Array()//钓到过 let vecUnCatched = Array() let gofishList = this.findMeans(IDDef.FISHING) as composeObj for (let [idkey, valueObj] of gofishList.getMemberMap()) { let catchProp = valueObj.getPropByType(propType.catch) if(catchProp) { vecAbleFishId = vecAbleFishId.concat((catchProp as PropCatch).getAble()) } } //已钓列表 for(let idx=0;idx0) vecCatched.push(fish) else vecUnCatched.push(fish) } } let allfee = 0 //perOwn概率捕获已捕获的鱼,perUnOwn概率捕获未捕获的鱼 let vecNewCatchedId:Array=new Array() let mapCatchedId:Map=new Map() function randInt(){ return Math.round((Math.random()*10000000)) } while(time>0) { time--; if(vecCatched.length==0 && vecUnCatched.length==0)break;//没有可钓鱼 let cacheIdx = 0 //没有捕获过鱼,就直接在可捕获中捕获,没有可捕获的,就在已经捕获中捕获。否则按比例捕获 if(vecCatched.length==0) cacheIdx = 1; else if(vecUnCatched.length==0) cacheIdx = 0; else if(randInt()%100<=perOwn)// cacheIdx = 0 else cacheIdx = 1 if(cacheIdx==0) { let randIdx = randInt()%vecCatched.length; let fishId = vecCatched[randIdx].getId() let catchedNum = mapCatchedId.get(fishId) || 0 mapCatchedId.set(fishId,catchedNum+1) let arrSale = dataManager.ins().getSaleById(fishId) if(arrSale) allfee += arrSale._price } else { let randIdx = randInt()%vecUnCatched.length; let fishId = vecUnCatched[randIdx].getId() let findObj = this.findMeans(fishId) if(findObj) { (findObj as valueObj).setCount(1)//钓到过 vecCatched.push(findObj) vecUnCatched.splice(randIdx,1) mapCatchedId.set(fishId,1)//新解锁的不能卖 vecNewCatchedId.push(fishId) } } } return {mapCatched:mapCatchedId,vecNewCatched:vecNewCatchedId,allFee:allfee} } //签到 doSignInByWeekDay(wDay:number){ let sInProp = this.getPropByType(propType.signIn) as PropSignIn if(sInProp.isSignAble(wDay)==true){ return true; } return false; } }