mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +00:00
fix sendBoat() causing lag/freezes towards end game, add arrow emojis
This commit is contained in:
@@ -95,16 +95,16 @@
|
||||
<tr>
|
||||
<td><button class="emoji-button">🦉</button></td>
|
||||
<td><button class="emoji-button">🌵</button></td>
|
||||
<td><button class="emoji-button">🥑</button></td>
|
||||
<td><button class="emoji-button">🚀</button></td>
|
||||
<td><button class="emoji-button">🎨</button></td>
|
||||
<td><button class="emoji-button">➡️</button></td>
|
||||
<td><button class="emoji-button">⬅️</button></td>
|
||||
<td><button class="emoji-button">↙️</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button class="emoji-button">🦋</button></td>
|
||||
<td><button class="emoji-button">🍄</button></td>
|
||||
<td><button class="emoji-button">🍉</button></td>
|
||||
<td><button class="emoji-button">🛵</button></td>
|
||||
<td><button class="emoji-button">🏆</button></td>
|
||||
<td><button class="emoji-button">↖️</button></td>
|
||||
<td><button class="emoji-button">↗️</button></td>
|
||||
<td><button class="emoji-button">⬆️</button></td>
|
||||
<td><button class="emoji-button">↘️</button></td>
|
||||
<td><button class="emoji-button">⬇️</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
+9
-8
@@ -47,8 +47,14 @@ export interface Lobby {
|
||||
numClients: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const EmojiSchema = z.string().refine(
|
||||
(val) => {
|
||||
return /\p{Emoji}/u.test(val);
|
||||
},
|
||||
{
|
||||
message: "Must contain at least one emoji character"
|
||||
}
|
||||
);
|
||||
// Zod schemas
|
||||
const BaseIntentSchema = z.object({
|
||||
type: z.enum(['attack', 'spawn', 'boat', 'name', 'targetPlayer', 'emoji']),
|
||||
@@ -119,12 +125,7 @@ export const EmojiIntentSchema = BaseIntentSchema.extend({
|
||||
type: z.literal('emoji'),
|
||||
sender: z.string(),
|
||||
recipient: z.string(),
|
||||
emoji: z.string().refine(
|
||||
(val) => /^\p{Emoji}$/u.test(val),
|
||||
{
|
||||
message: "Must be a single emoji"
|
||||
}
|
||||
)
|
||||
emoji: EmojiSchema,
|
||||
})
|
||||
|
||||
const IntentSchema = z.union([
|
||||
|
||||
@@ -30,12 +30,12 @@ export const devConfig = new class extends DefaultConfig {
|
||||
// return 1
|
||||
// }
|
||||
|
||||
startTroops(playerInfo: PlayerInfo): number {
|
||||
// if (playerInfo.isBot) {
|
||||
// return 5000
|
||||
// }
|
||||
return 50000
|
||||
}
|
||||
// startTroops(playerInfo: PlayerInfo): number {
|
||||
// // if (playerInfo.isBot) {
|
||||
// // return 5000
|
||||
// // }
|
||||
// return 50000
|
||||
// }
|
||||
|
||||
// troopAdditionRate(player: Player): number {
|
||||
// if (player.isBot()) {
|
||||
|
||||
@@ -149,12 +149,14 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
sendBoat(tries: number = 0) {
|
||||
if (tries > 100) {
|
||||
sendBoat(tries: number = 0, oceanShore: Tile[] = null) {
|
||||
if (tries > 10) {
|
||||
return
|
||||
}
|
||||
|
||||
const oceanShore = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
|
||||
if (oceanShore == null) {
|
||||
oceanShore = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
|
||||
}
|
||||
if (oceanShore.length == 0) {
|
||||
return
|
||||
}
|
||||
@@ -171,7 +173,7 @@ export class FakeHumanExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const dst = this.random.randElement(otherShore)
|
||||
if (this.isSmallIsland(dst)) {
|
||||
continue
|
||||
@@ -188,8 +190,7 @@ export class FakeHumanExecution implements Execution {
|
||||
))
|
||||
return
|
||||
}
|
||||
this.sendBoat(tries + 1)
|
||||
|
||||
this.sendBoat(tries + 1, oceanShore)
|
||||
}
|
||||
|
||||
randomLand(): Tile {
|
||||
@@ -216,7 +217,7 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
|
||||
isSmallIsland(tile: Tile): boolean {
|
||||
return bfs(tile, and((t) => t.isLand(), dist(tile, 50))).size < 50
|
||||
return bfs(tile, and((t) => t.isLand(), dist(tile, 10))).size < 50
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
|
||||
Reference in New Issue
Block a user