Merge branch 'master' of http://git.kingsome.cn/node/card_svr
This commit is contained in:
commit
2f4e95df53
@ -1,6 +1,7 @@
|
|||||||
import { singleton } from '../decorators/singleton.decorator'
|
import { singleton } from '../decorators/singleton.decorator'
|
||||||
import { GameEnv } from './GameEnv'
|
import { GameEnv } from './GameEnv'
|
||||||
import { CardGameState } from '../rooms/schema/CardGameState'
|
import { CardGameState } from '../rooms/schema/CardGameState'
|
||||||
|
import { checkBitIdx, checkBitNumber } from '../utils/number.util'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个回合是否能多次吃牌
|
* 一个回合是否能多次吃牌
|
||||||
@ -66,11 +67,18 @@ export class RoomOptions {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
public initGameRule(state: CardGameState) {
|
public initGameRule(state: CardGameState, val: number) {
|
||||||
|
if (val) {
|
||||||
|
state.rules.set(RULE_CANEAT, checkBitNumber(val, 1))
|
||||||
|
state.rules.set(RULE_MULTIPLEEAT, checkBitNumber(val, 2))
|
||||||
|
state.rules.set(RULE_DROPCARD, checkBitNumber(val, 3))
|
||||||
|
state.rules.set(RULE_SINGLEEAT, checkBitNumber(val, 4))
|
||||||
|
} else {
|
||||||
state.rules.set(RULE_CANEAT, this.canEat({advMode: state.advMode}))
|
state.rules.set(RULE_CANEAT, this.canEat({advMode: state.advMode}))
|
||||||
state.rules.set(RULE_MULTIPLEEAT, this.multipleEat())
|
state.rules.set(RULE_MULTIPLEEAT, this.multipleEat())
|
||||||
state.rules.set(RULE_DROPCARD, this.autoDiscard())
|
state.rules.set(RULE_DROPCARD, this.autoDiscard())
|
||||||
state.rules.set(RULE_SINGLEEAT, this.singleEat())
|
state.rules.set(RULE_SINGLEEAT, this.singleEat())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,11 @@ export class GeneralRoom extends Room {
|
|||||||
if (options.score) {
|
if (options.score) {
|
||||||
this.score = options.score
|
this.score = options.score
|
||||||
}
|
}
|
||||||
new RoomOptions().initGameRule(this.state)
|
let val = 0
|
||||||
|
if (options.debug_cv) {
|
||||||
|
val = +options.debug_cv
|
||||||
|
}
|
||||||
|
new RoomOptions().initGameRule(this.state, val)
|
||||||
this.battleMan.init(cs, this)
|
this.battleMan.init(cs, this)
|
||||||
this.clock.start()
|
this.clock.start()
|
||||||
this.state.gameState = GameStateConst.STATE_WAIT_JOIN
|
this.state.gameState = GameStateConst.STATE_WAIT_JOIN
|
||||||
|
@ -8,3 +8,20 @@ export function getRandom(max: number, min: number): number {
|
|||||||
min = min || 0;
|
min = min || 0;
|
||||||
return Math.floor(Math.random()*(max-min)+min);
|
return Math.floor(Math.random()*(max-min)+min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setBitVal(value: number, index: number, yes: boolean) {
|
||||||
|
if (yes) {
|
||||||
|
value |= (1<<index)
|
||||||
|
} else {
|
||||||
|
value &= ~(1<<index)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkBitIdx(value: number, index: number): boolean {
|
||||||
|
return ((value >> (index)) & 1 ) == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkBitNumber(value: number, index: number): number {
|
||||||
|
return (((value >> (index)) & 1 ) == 1) ? 1 : 0
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user