-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5d8209
commit 2799020
Showing
60 changed files
with
1,495 additions
and
1,819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { CaughtPet, spet } from './pet.js'; | ||
export { PetLocation } from './PetLocation.js'; | ||
export { SEAPetStore } from './PetStore.js'; | ||
export { CaughtPet, spet } from './pet.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 60 additions & 66 deletions
126
packages/launcher/src/builtin/realm/LevelCourageTower.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,73 @@ | ||
import type { AnyFunction, ILevelBattle } from '@sea/core'; | ||
import type { AnyFunction, LevelBattle } from '@sea/core'; | ||
import type { LevelData } from '@sea/mod-type'; | ||
|
||
import { LevelAction, socket } from '@sea/core'; | ||
import type { LevelMeta, LevelData as SEALevelData, TaskRunner } from '@sea/mod-type'; | ||
import { task } from '@sea/mod-type'; | ||
|
||
export interface LevelData extends SEALevelData { | ||
export interface Data extends LevelData { | ||
stimulation: boolean; | ||
rewardReceived: boolean; | ||
} | ||
|
||
export interface LevelOption { | ||
stimulation: boolean; | ||
sweep: boolean; | ||
} | ||
|
||
export default (logger: AnyFunction, battle: (name: string) => ILevelBattle) => { | ||
class LevelCourageTower implements TaskRunner<LevelData> { | ||
data: LevelData = { | ||
remainingTimes: 0, | ||
progress: 0, | ||
rewardReceived: false, | ||
stimulation: false | ||
}; | ||
|
||
static readonly meta: LevelMeta = { | ||
export default (logger: AnyFunction, battle: (name: string) => LevelBattle) => | ||
task({ | ||
meta: { | ||
name: '勇者之塔', | ||
maxTimes: 5, | ||
id: 'LevelCourageTower' | ||
}; | ||
|
||
get meta() { | ||
return LevelCourageTower.meta; | ||
} | ||
|
||
get name() { | ||
return LevelCourageTower.meta.name; | ||
} | ||
|
||
logger = logger; | ||
|
||
constructor(public option: LevelOption) {} | ||
|
||
async update() { | ||
const bits = (await socket.bitSet(636, 1000577)).map(Boolean); | ||
const buf = await socket.sendByQueue(42397, [117]); | ||
const realmInfo = new DataView(buf!); | ||
|
||
this.data.stimulation = bits[0]; | ||
this.data.rewardReceived = bits[1]; | ||
this.data.remainingTimes = this.meta.maxTimes - realmInfo.getUint32(8); | ||
} | ||
|
||
next(): string { | ||
if (!this.data.rewardReceived) { | ||
if (this.data.remainingTimes > 0) { | ||
return LevelAction.BATTLE; | ||
} else { | ||
return LevelAction.AWARD; | ||
} | ||
}, | ||
configSchema: { | ||
stimulation: { | ||
name: '勇者之塔双倍', | ||
type: 'checkbox', | ||
default: false | ||
}, | ||
sweep: { | ||
name: '勇者之塔扫荡', | ||
type: 'checkbox', | ||
default: false | ||
} | ||
return LevelAction.STOP; | ||
} | ||
}, | ||
runner: (meta, options) => ({ | ||
logger, | ||
data: { | ||
remainingTimes: 0, | ||
progress: 0, | ||
rewardReceived: false, | ||
stimulation: false | ||
} as Data, | ||
async update() { | ||
const bits = (await socket.bitSet(636, 1000577)).map(Boolean); | ||
const buf = await socket.sendByQueue(42397, [117]); | ||
const realmInfo = new DataView(buf!); | ||
|
||
selectLevelBattle() { | ||
return battle('LevelCourageTower'); | ||
} | ||
|
||
readonly actions: Record<string, () => Promise<void>> = { | ||
battle: async () => { | ||
await socket.sendByQueue(CommandID.FIGHT_H5_PVE_BOSS, [117, 30, 1]); | ||
this.data.stimulation = bits[0]; | ||
this.data.rewardReceived = bits[1]; | ||
this.data.remainingTimes = meta.maxTimes - realmInfo.getUint32(8); | ||
}, | ||
|
||
award: async () => { | ||
await socket.sendByQueue(42395, [117, 4, 0, 0]); | ||
next() { | ||
if (!this.data.rewardReceived) { | ||
if (this.data.remainingTimes > 0) { | ||
return options.sweep ? 'sweep' : LevelAction.BATTLE; | ||
} else { | ||
return LevelAction.AWARD; | ||
} | ||
} | ||
return LevelAction.STOP; | ||
}, | ||
selectLevelBattle() { | ||
return battle('LevelCourageTower'); | ||
}, | ||
actions: { | ||
async battle() { | ||
await socket.sendByQueue(CommandID.FIGHT_H5_PVE_BOSS, [117, 30, 1]); | ||
}, | ||
async award() { | ||
await socket.sendByQueue(42395, [117, 4, 0, 0]); | ||
}, | ||
async sweep() { | ||
// TODO | ||
} | ||
} | ||
}; | ||
} | ||
|
||
return LevelCourageTower; | ||
}; | ||
}) | ||
}); |
Oops, something went wrong.