Compare commits
7 Commits
9a1c18f815
...
webbeta
| Author | SHA1 | Date | |
|---|---|---|---|
| 448fc8aebe | |||
| 7dab0ed143 | |||
| a13748b833 | |||
| 11e531fef2 | |||
| d198e8906f | |||
| d677ff8ae9 | |||
| cbc961b7c4 |
118
main.py
118
main.py
@@ -1,3 +1,5 @@
|
||||
from datetime import time
|
||||
import datetime
|
||||
import discord
|
||||
import os
|
||||
from discord.ext import tasks
|
||||
@@ -42,59 +44,67 @@ async def on_ready():
|
||||
|
||||
@tasks.loop(seconds=5)
|
||||
async def task_loop():
|
||||
await bot.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.watching,
|
||||
name=str(len(bot.tracked_games)) + " Servers.",
|
||||
)
|
||||
)
|
||||
for game in bot.tracked_games:
|
||||
channel = bot.get_channel(game.channelId)
|
||||
if channel is None:
|
||||
continue
|
||||
# handle turn ticks
|
||||
new_turn = game.get_turn()
|
||||
if new_turn != game.turn and new_turn.isdigit():
|
||||
game.update_turn()
|
||||
pingstr = ""
|
||||
if game.members:
|
||||
pingstr += "-# "
|
||||
for member in game.members:
|
||||
pingstr += "<@" + str(member) + "> "
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"** has advanced to turn '
|
||||
+ game.turn
|
||||
+ " \n"
|
||||
+ pingstr
|
||||
try:
|
||||
# print(str(datetime.datetime.now()) + ": Loop running.")
|
||||
await bot.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.watching,
|
||||
name=str(len(bot.tracked_games)) + " Servers.",
|
||||
)
|
||||
game.to_json()
|
||||
|
||||
# handle uploaded turns
|
||||
turns = game.get_new_turns()
|
||||
if turns != {}:
|
||||
for key in turns:
|
||||
value = turns[key]
|
||||
if value == "Turn played":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has played their turn."
|
||||
)
|
||||
if value == "Eliminated":
|
||||
await channel.send(
|
||||
'Game **"' + game.name + '"**: ' + key + " has been eliminated."
|
||||
)
|
||||
if value == "Turn unfinished":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has marked their turn as unfinished."
|
||||
)
|
||||
game.update_players()
|
||||
)
|
||||
for game in bot.tracked_games:
|
||||
channel = bot.get_channel(game.channelId)
|
||||
if channel is None:
|
||||
continue
|
||||
# handle turn ticks
|
||||
new_turn = game.get_turn()
|
||||
if new_turn != game.turn and new_turn.isdigit():
|
||||
game.update_turn()
|
||||
pingstr = ""
|
||||
if game.members:
|
||||
pingstr += "-# "
|
||||
for member in game.members:
|
||||
pingstr += "<@" + str(member) + "> "
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"** has advanced to turn '
|
||||
+ game.turn
|
||||
+ " \n"
|
||||
+ pingstr
|
||||
)
|
||||
game.to_json()
|
||||
|
||||
# handle uploaded turns
|
||||
turns = game.get_new_turns()
|
||||
if turns != {}:
|
||||
for key in turns:
|
||||
value = turns[key]
|
||||
if value == "Turn played":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has played their turn."
|
||||
)
|
||||
if value == "Eliminated":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has been eliminated."
|
||||
)
|
||||
if value == "Turn unfinished":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has marked their turn as unfinished."
|
||||
)
|
||||
game.update_players()
|
||||
game.to_json()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
51
webui.py
51
webui.py
@@ -77,9 +77,9 @@ def creator_page():
|
||||
)
|
||||
)
|
||||
|
||||
# client_start = ui.checkbox("Allow clients to start the game")
|
||||
checkbox_container = ui.row()
|
||||
with checkbox_container:
|
||||
client_start = ui.checkbox("Allow clients to start the game", value=True)
|
||||
team_game = ui.checkbox("Disciple Game")
|
||||
clustered_start = ui.checkbox("Clustered Spawns (Disciple games only)")
|
||||
random_start_research = ui.checkbox("Random Start Research")
|
||||
@@ -91,16 +91,31 @@ def creator_page():
|
||||
no_new_ai = ui.checkbox("Disable Becoming AI Controlled")
|
||||
vwrap = ui.checkbox("North South Wrapping")
|
||||
hwrap = ui.checkbox("East West Wrapping")
|
||||
description_container = ui.row()
|
||||
toggle_container = ui.row()
|
||||
# TODO: Are these containers still needed?
|
||||
with toggle_container:
|
||||
with ui.row():
|
||||
ui.label("Event Rarity").classes("w-40")
|
||||
ui.label("Provinces per player").classes("w-36")
|
||||
ui.label("Story Events")
|
||||
|
||||
with ui.row():
|
||||
event_rarity = ui.toggle({1: "Common", 2: "Rare"}, value=1)
|
||||
random_map = ui.toggle([10, 15, 20], value=15)
|
||||
with description_container:
|
||||
ui.label("Event Rarity")
|
||||
# TODO: Fix Padding
|
||||
ui.label("Provinces per player:")
|
||||
story_events = ui.toggle({0: "None", 1: "Some", 2: "All"}, value=2)
|
||||
|
||||
ui.label("Victory Condition")
|
||||
# I have to do this to pass by reference?? This is absurd.
|
||||
conq_all = [True]
|
||||
thrones = [(0, 0, 0)]
|
||||
required_apoints = [0]
|
||||
with ui.row():
|
||||
ui.radio({1: "Conquest", 2: "Thrones Of Ascension"}).props(
|
||||
"inline"
|
||||
).on_value_change(
|
||||
lambda e: handle_thrones(
|
||||
e, throne_container, conq_all, thrones, required_apoints
|
||||
)
|
||||
)
|
||||
|
||||
throne_container = ui.row()
|
||||
with ui.row():
|
||||
ui.label("Gold Multiplier:").classes("w-36")
|
||||
richness = ui.input(
|
||||
@@ -164,11 +179,29 @@ def creator_page():
|
||||
resources=int(resources.value),
|
||||
richness=int(richness.value),
|
||||
supplies=int(supplies.value),
|
||||
story_events=int(story_events.value),
|
||||
conq_all=conq_all,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def handle_thrones(value, throne_container, conq_all, thrones, required_apoints):
|
||||
if value == 1:
|
||||
throne_container.clear()
|
||||
conq_all[0] = False
|
||||
return
|
||||
with throne_container:
|
||||
with ui.row():
|
||||
thrones = (
|
||||
ui.input(label="Level 1"),
|
||||
ui.input(label="Level 2"),
|
||||
ui.input(label="Level 3"),
|
||||
)
|
||||
required_apoints = ui.input(label="Required Ascension Points")
|
||||
return False, thrones, required_apoints
|
||||
|
||||
|
||||
def create_ai_table(era, table_container, ai_slots):
|
||||
# TODO: move this somewhere else
|
||||
AI_LEVELS = [
|
||||
|
||||
Reference in New Issue
Block a user