fix sendBoat() causing lag/freezes towards end game, add arrow emojis

This commit is contained in:
evanpelle
2024-10-05 11:35:40 -07:00
parent df28ee169f
commit 39d5e8d72f
4 changed files with 31 additions and 29 deletions
+8 -8
View File
@@ -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
View File
@@ -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([
+6 -6
View File
@@ -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()) {
+8 -7
View File
@@ -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 {