-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* work done so far on notifications * somewhat improved notifications logic * update constants * minimum game version check and some other updates to notifications * update deps * some bug fixes * fix linting issues
- Loading branch information
1 parent
9f1c86b
commit 4c25fc8
Showing
14 changed files
with
543 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { SUPPORT_MESSAGE } from '@constants'; | ||
import type { Notification, UncivJSON } from '@localTypes/unciv'; | ||
import random from 'random'; | ||
|
||
const defaultNotification = 'Welcome to UncivServer.xyz!'; | ||
const defaultNotificationIcon = 'NotificationIcons/RobotArm'; | ||
|
||
const notificationIcons = [defaultNotificationIcon, 'NotificationIcons/ServerRack']; | ||
|
||
const randomNotifications = [ | ||
`${defaultNotification} Again!`, | ||
"It's your turn!", | ||
'Time to make some moves!', | ||
'Hi! Server here. Have a nice day!', | ||
"Don't forget to press 'Next Turn' when you're done!", | ||
"Hi, there! @touhidurrr here from UncivServer.xyz. Don't forget I might be watching your every move...", | ||
"Let's speed through some turns!", | ||
]; | ||
|
||
const supportNotificationIcons = ['NotificationIcons/DollarSign']; | ||
|
||
const randomSupportNotifications = [SUPPORT_MESSAGE]; | ||
|
||
const supportNotificationsProbability = 0.2; | ||
|
||
export function generateRandomNotification(gameData: UncivJSON): Notification { | ||
let text = defaultNotification; | ||
let icons = [defaultNotificationIcon]; | ||
|
||
if (gameData.turns) { | ||
if (random.float() < supportNotificationsProbability) { | ||
text = random.choice(randomSupportNotifications)!; | ||
icons[0] = random.choice(supportNotificationIcons)!; | ||
} else { | ||
text = random.choice(randomNotifications)!; | ||
icons[0] = random.choice(notificationIcons)!; | ||
} | ||
} | ||
|
||
return { | ||
text, | ||
icons, | ||
category: 'General', | ||
actions: [], | ||
}; | ||
} |
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,5 @@ | ||
import random from 'random'; | ||
|
||
export function getRandomColor() { | ||
return Math.floor(0x1000000 * Math.random()); | ||
return random.int(0x000000, 0xffffff); | ||
} |
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
Oops, something went wrong.