增加一些机器人日志的信息
This commit is contained in:
parent
ed00f17e21
commit
f3751495dd
@ -186,7 +186,13 @@ export class Robot {
|
|||||||
}
|
}
|
||||||
let self = this
|
let self = this
|
||||||
let cardArr = [...self.player.cards.values()]
|
let cardArr = [...self.player.cards.values()]
|
||||||
let result = assistantUtil.discard({cardArr, eatCard: targetCard, rate: this.cheatRate, noEatRate: this.noEatRate, noTripleRate: this.noTripleRate})
|
let result = assistantUtil.discard({cardArr,
|
||||||
|
eatCard: targetCard,
|
||||||
|
rate: this.cheatRate,
|
||||||
|
noEatRate: this.noEatRate,
|
||||||
|
noTripleRate: this.noTripleRate,
|
||||||
|
playerId: this.sessionId
|
||||||
|
})
|
||||||
let cards = result.cards;
|
let cards = result.cards;
|
||||||
if (!cards || cards.length == 0) {
|
if (!cards || cards.length == 0) {
|
||||||
return
|
return
|
||||||
|
@ -198,7 +198,12 @@ export class RobotClient implements Client {
|
|||||||
private async eatOrGiveUp() {
|
private async eatOrGiveUp() {
|
||||||
let targetCard = [...this.svrstate.cards.values()][0]
|
let targetCard = [...this.svrstate.cards.values()][0]
|
||||||
let cardArr = [...this.selfPlayer.cards.values()]
|
let cardArr = [...this.selfPlayer.cards.values()]
|
||||||
let result = assistantUtil.discard({cardArr, eatCard: targetCard, rate: this.cheatRate, noEatRate: this.noEatRate, noTripleRate: this.noTripleRate})
|
let result = assistantUtil.discard({cardArr,
|
||||||
|
eatCard: targetCard,
|
||||||
|
rate: this.cheatRate,
|
||||||
|
noEatRate: this.noEatRate,
|
||||||
|
playerId: this.sessionId,
|
||||||
|
noTripleRate: this.noTripleRate})
|
||||||
let tmpCards = result.cards
|
let tmpCards = result.cards
|
||||||
let next = this.giveup.bind(this)
|
let next = this.giveup.bind(this)
|
||||||
if (tmpCards.length > 1 && targetCard.type === 1) {
|
if (tmpCards.length > 1 && targetCard.type === 1) {
|
||||||
|
@ -102,11 +102,11 @@ function seekSeq(pointMap: Map<number, Card[]>, points: number[], special?: Card
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCheat(this: any, cardArr: Card[], rate: number, eatCard?: Card) {
|
function parseCheat(this: any, playerId: string, cardArr: Card[], rate: number, eatCard?: Card) {
|
||||||
let minCount = eatCard ? new GameEnv().otherEatCount : new GameEnv().selfEatCount
|
let minCount = eatCard ? new GameEnv().otherEatCount : new GameEnv().selfEatCount
|
||||||
if (cardArr.length >= minCount && rate > 0) {
|
if (cardArr.length >= minCount && rate > 0) {
|
||||||
let random = getRandom(0, 100)
|
let random = getRandom(0, 100)
|
||||||
robotLog(`[discard] check cheat ^_^ random: ${random}, rate: ${rate}`)
|
robotLog(`(${playerId})[discard] check cheat ^_^ random: ${random}, rate: ${rate}`)
|
||||||
if (random <= rate) {
|
if (random <= rate) {
|
||||||
let max = Math.min(minCount+2, cardArr.length + 1)
|
let max = Math.min(minCount+2, cardArr.length + 1)
|
||||||
let randomCount = getRandom(minCount, max)
|
let randomCount = getRandom(minCount, max)
|
||||||
@ -172,7 +172,7 @@ function parseCheat(this: any, cardArr: Card[], rate: number, eatCard?: Card) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const oneCardArr: Card[] = cardArr.randomGet(1)
|
const oneCardArr: Card[] = cardArr.randomGet(1)
|
||||||
robotLog(`[discard] no cheat: ${oneCardArr[0].number}`)
|
robotLog(`(${playerId})[discard] no cheat: ${oneCardArr[0].number}`)
|
||||||
return {cards: oneCardArr }
|
return {cards: oneCardArr }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,12 +227,14 @@ let assistantUtil = {
|
|||||||
/**
|
/**
|
||||||
* 出牌
|
* 出牌
|
||||||
*/
|
*/
|
||||||
discard({cardArr, eatCard, rate, noEatRate, noTripleRate}:
|
discard({cardArr, eatCard, rate, noEatRate, noTripleRate, playerId}:
|
||||||
{cardArr: Card[],
|
{cardArr: Card[],
|
||||||
eatCard?: Card,
|
eatCard?: Card,
|
||||||
rate: number,
|
rate: number,
|
||||||
noEatRate: number,
|
noEatRate: number,
|
||||||
noTripleRate: number}): {cards: Card[], nums?: number[]} {
|
noTripleRate: number,
|
||||||
|
playerId?: string
|
||||||
|
}): {cards: Card[], nums?: number[]} {
|
||||||
const pointCardArr = cardArr.filter(c => c.type == CardType.general || c.type == CardType.variable_unit)
|
const pointCardArr = cardArr.filter(c => c.type == CardType.general || c.type == CardType.variable_unit)
|
||||||
const {
|
const {
|
||||||
selfEat,
|
selfEat,
|
||||||
@ -242,27 +244,27 @@ let assistantUtil = {
|
|||||||
eatSecs,
|
eatSecs,
|
||||||
normalSecs
|
normalSecs
|
||||||
} = this.checkDiscard({cardArr: pointCardArr, eatCard})
|
} = this.checkDiscard({cardArr: pointCardArr, eatCard})
|
||||||
robotLog(`[discard] check: eatself: ${selfEat}, eatother: ${otherEat}, self: ${pointCardArr.map(o=>o.number)}, target: ${eatCard?.number}`)
|
robotLog(`(${playerId})[discard] check: eatself: ${selfEat}, eatother: ${otherEat}, self: ${pointCardArr.map(o=>o.number)}, target: ${eatCard?.number}`)
|
||||||
let results: Card[] = []
|
let results: Card[] = []
|
||||||
let random = getRandom(0, 100)
|
let random = getRandom(0, 100)
|
||||||
if (otherEat && random <= noEatRate) {
|
if (otherEat && random <= noEatRate) {
|
||||||
robotLog(`[discard] cat eat, but random(${random}) <= cfg(${noEatRate})`)
|
robotLog(`(${playerId})[discard] cat eat, but random(${random}) <= cfg(${noEatRate})`)
|
||||||
} else if (otherEat && random > noEatRate) {
|
} else if (otherEat && random > noEatRate) {
|
||||||
results = eatPairs.length > 0? eatPairs : eatSecs
|
results = eatPairs.length > 0? eatPairs : eatSecs
|
||||||
robotLog(`[discard] eat card random(${random}) > cfg(${noEatRate}) ${results.map(o=>o.number)}`)
|
robotLog(`(${playerId})[discard] eat card random(${random}) > cfg(${noEatRate}) ${results.map(o=>o.number)}`)
|
||||||
}
|
}
|
||||||
random = getRandom(0, 100)
|
random = getRandom(0, 100)
|
||||||
if (selfEat && results.length == 0 && random <= noTripleRate) {
|
if (selfEat && results.length == 0 && random <= noTripleRate) {
|
||||||
robotLog(`[discard] can hu, but random(${random}) <= cfg(${noTripleRate})`)
|
robotLog(`(${playerId})[discard] can hu, but random(${random}) <= cfg(${noTripleRate})`)
|
||||||
} if (selfEat && results.length == 0 && random > noTripleRate) {
|
} if (selfEat && results.length == 0 && random > noTripleRate) {
|
||||||
results = normalPairs.length > 0 ? normalPairs : normalSecs
|
results = normalPairs.length > 0 ? normalPairs : normalSecs
|
||||||
robotLog(`[discard] hu card random(${random}) > cfg(${noTripleRate}) ${results.map(o=>o.number)}`)
|
robotLog(`(${playerId})[discard] hu card random(${random}) > cfg(${noTripleRate}) ${results.map(o=>o.number)}`)
|
||||||
}
|
}
|
||||||
if (results.length == 0) {
|
if (results.length == 0) {
|
||||||
results = cardArr.randomGet(1)
|
results = cardArr.randomGet(1)
|
||||||
}
|
}
|
||||||
if (!selfEat && !otherEat) {
|
if (!selfEat && !otherEat) {
|
||||||
return parseCheat(cardArr, rate, eatCard)
|
return parseCheat(playerId, cardArr, rate, eatCard)
|
||||||
}
|
}
|
||||||
return {cards: results}
|
return {cards: results}
|
||||||
},
|
},
|
||||||
@ -345,11 +347,11 @@ let assistantUtil = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
error(`无法选择随从或法术, 随从数: ${ petCount }, 法术牌数量: ${ spellCards.length }`)
|
error(`(${dstPlayer.id})无法选择随从或法术, 随从数: ${ petCount }, 法术牌数量: ${ spellCards.length }`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect)
|
let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect)
|
||||||
robotLog(`select_pet ${ dstPlayer.id }: ${ result.effect } 类型: ${ effectMap.get(result.effect).type_id == EffectType.skill ? '法术' : '随从' }, targetType: ${ targetType }, oldpos: ${oldpos}`)
|
robotLog(`(${dstPlayer.id})select_pet ${ dstPlayer.id }: ${ result.effect } 类型: ${ effectMap.get(result.effect).type_id == EffectType.skill ? '法术' : '随从' }, targetType: ${ targetType }, oldpos: ${oldpos}`)
|
||||||
let targetPlayer
|
let targetPlayer
|
||||||
let targetPos
|
let targetPos
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user