Average improvements

fight-fixes
bobloy 7 years ago
parent 2be0b05994
commit e6f566dfdc

@ -2,7 +2,6 @@ import asyncio
import discord import discord
# Import all roles here # Import all roles here
from werewolf.role import Role
from werewolf.roles.vanillawerewolf import VanillaWerewolf from werewolf.roles.vanillawerewolf import VanillaWerewolf
from werewolf.roles.villager import Villager from werewolf.roles.villager import Villager
from werewolf.roles.seer import Seer from werewolf.roles.seer import Seer
@ -10,35 +9,41 @@ from werewolf.roles.seer import Seer
# All roles in this list for iterating # All roles in this list for iterating
role_list = [Villager, VanillaWerewolf] role_list = [Villager, VanillaWerewolf]
#Example code: """
# 0 = Villager Example code:
# 1 = VanillaWerewolf 0 = Villager
# E1 = Random Town 1 = VanillaWerewolf
# R1 = Random Werewolf E1 = Random Town
# J1 = Benign Neutral R1 = Random Werewolf
J1 = Benign Neutral
# 0001-1112E11R112P2 0001-1112E11R112P2
# 0,0,0,1,11,12,E1,R1,R1,R1,R2,P2 0,0,0,1,11,12,E1,R1,R1,R1,R2,P2
pre-letter = exact role position
double digit position preempted by `-`
"""
# pre-letter = exact role position
# double digit position pre-empted by `-`
async def parse_code(code): async def parse_code(code):
"""Do the magic described above"""
out = [] out = []
#Do the magic described above
decode = code.copy() # for now, pass exact names decode = code.copy() # for now, pass exact names
for role_id in decode: for role_id in decode:
print(role_id) print(role_id)
if role_id == "Villager": if role_id == "Villager":
role = Villager role = Villager
if role_id == "VanillaWerewolf": elif role_id == "VanillaWerewolf":
role = VanillaWerewolf role = VanillaWerewolf
if role_id == "Seer": elif role_id == "Seer":
role = Seer role = Seer
else: # Fail to parse
return None
out.append(role) out.append(role)
return out return out
async def build_game(channel: discord.TextChannel): async def build_game(channel: discord.TextChannel):
await channel.send("Not currently available") await channel.send("Not currently available")

@ -1,8 +1,6 @@
import asyncio import asyncio
import discord import discord
from datetime import datetime, timedelta
import random import random
from werewolf.player import Player from werewolf.player import Player
@ -14,7 +12,7 @@ class Game:
""" """
Base class to run a single game of Werewolf Base class to run a single game of Werewolf
""" """
default_secret_channel = { default_secret_channel = {
"channel": None, "channel": None,
"players": [], "players": [],
@ -59,10 +57,7 @@ class Game:
self.vote_groups = {} # ID : VoteGroup() self.vote_groups = {} # ID : VoteGroup()
self.night_results = [] self.night_results = []
self.loop = asyncio.get_event_loop() self.loop = asyncio.get_event_loop()
async def setup(self, ctx): async def setup(self, ctx):
@ -91,7 +86,8 @@ class Game:
self.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True) self.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True)
} }
self.channel_category = await self.guild.create_category("ww-game", overwrites=overwrite, reason="New game of werewolf") self.channel_category = await self.guild.create_category("ww-game", overwrites=overwrite, reason="New game of "
"werewolf")
for player in self.players: for player in self.players:
overwrite[player.member] = discord.PermissionOverwrite(read_messages=True) overwrite[player.member] = discord.PermissionOverwrite(read_messages=True)

@ -1,8 +1,6 @@
import asyncio import asyncio
import discord import discord
from datetime import datetime, timedelta
class Player: class Player:
""" """

@ -1,5 +1,6 @@
import asyncio import asyncio
class Role: class Role:
""" """
Base Role class for werewolf game Base Role class for werewolf game

@ -97,12 +97,12 @@ class Seer(Role):
# async def _at_day_end(self): # async def _at_day_end(self):
# pass # pass
async def _at_night_start(self): async def _at_night_start(self, data=None):
await self.game.generate_targets(self.player.member) await self.game.generate_targets(self.player.member)
await self.player.send_dm("{}\n**Pick a target to see tonight**\n") await self.player.send_dm("{}\n**Pick a target to see tonight**\n")
async def _at_night_end(self): async def _at_night_end(self, data=None):
target = await self.game.visit(self.see_target) target = await self.game.visit(self.see_target)
alignment = await target.see_alignment(self.player) alignment = await target.see_alignment(self.player)

@ -5,8 +5,6 @@ from discord.ext import commands
from redbot.core import Config from redbot.core import Config
from datetime import datetime, timedelta
from werewolf.game import Game from werewolf.game import Game
@ -48,9 +46,8 @@ class Werewolf:
await ctx.send("Failed to start a new game") await ctx.send("Failed to start a new game")
else: else:
await ctx.send("New game has started") await ctx.send("New game has started")
@commands.guild_only()
@commands.guild_only()
@ww.command() @ww.command()
async def join(self, ctx): async def join(self, ctx):
""" """
@ -157,7 +154,7 @@ class Werewolf:
# If multiple games, panic # If multiple games, panic
for game in self.games.values(): for game in self.games.values():
if await game.get_player_by_member(ctx.author): if await game.get_player_by_member(ctx.author):
break #game = game break # game = game
else: else:
await ctx.send("You're not part of any werewolf game") await ctx.send("You're not part of any werewolf game")
return return

Loading…
Cancel
Save