fight-fixes
bobloy 7 years ago
commit 2b4477bffa

@ -6,13 +6,14 @@ Cog Status
- ccrole: **Incomplete** - Not yet ported to v3
- challonge: **Incomplete** - Challonge integration with discord
- chatter: **Alpha** - Train your chat-bot to talk like your guild
- fight: **Incomplete** - Still in-progress, a massive project
- flag: **Incomplete** - Not yet ported to v3
- hangman: **Incomplete** - Not yet ported to v3
- immortal: **Private** - Designed for a specific server, not recommended to install
- leaver: **Incomplete** - Not yet ported to v3
- reactrestrict: **Beta** - Removes reactions by role per channel
- stealemoji: **Incomplete** - Steals any custom emoji it sees
- stealemoji: **Alpha** - Steals any custom emoji it sees
- werewolf: **Incomplete** - Play the classic party game Werewolf within discord
Many of these are functional in my V2 cogs at [Fox-Cogs v2](https://github.com/bobloy/Fox-Cogs)

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

@ -0,0 +1,42 @@
The files included here include a "bleeding" area so that they can be printed and cut to a poker-sized deck.
Type: Poker sized blank cards
Dimensions: 63mm x 88mm, 2.5" x 3.5"
Number of cards to print:
Yes: 10
No: 10
Fascist policy: 11
Liberal policy: 6
Membership - Liberal: 6
Membership - Fascist: 4
Board liberal: 1
Board fascist 5-6p: 1
Board fascist 7-8p: 1
Board fascist 9-10p: 1
Role - Liberal 1: 2
Role - Liberal 2: 1
Role - Liberal 3: 1
Role - Liberal 4: 1
Role - Liberal 5: 1
Role - Hitler: 1
Role - Fascist 1: 2
Role - Fascist 2: 1
President: 1
Chancellor: 1
Previous president 1
Previous chancellor 1
Draw pile 1
Discard pile 1
Special rules 1
You can also make this game in a reduced 54 cards deck by removing the membership cards (and use the Yes-No cards instead) and combining some of the board aids and boards.
Game is by Max Temkin
https://www.kickstarter.com/projects/maxtemkin/secret-hitler/

@ -0,0 +1,5 @@
from .werewolf import Werewolf
def setup(bot):
bot.add_cog(Werewolf(bot))

@ -0,0 +1,114 @@
import asyncio
import discord
from discord.ext import commands
from redbot.core import Config
from datetime import datetime, timedelta
from werewolf.game import Game
class Werewolf:
"""
Base to host werewolf on a guild
"""
def __init__(self, bot):
self.bot = bot
self.config = Config.get_conf(self, identifier=87101114101119111108102, force_registration=True)
default_global = {}
default_guild = {
}
self.config.register_global(**default_global)
self.config.register_guild(**default_guild)
self.games = {} # Active games stored here, id is per guild
@commands.group()
async def ww(self, ctx: commands.Context):
"""
Base command for this cog. Check help for the commands list.
"""
if ctx.invoked_subcommand is None:
await ctx.send_help()
@ww.command()
async def new(self, ctx, game_code):
"""
Create and join a new game of Werewolf
"""
game = self._get_game(ctx.guild, game_code)
if not game:
await ctx.send("Failed to start a new game")
else:
await ctx.send("New game has started")
@ww.command()
async def join(self, ctx):
"""
Joins a game of Werewolf
"""
game = self._get_game(ctx.guild)
if not game:
await ctx.send("No game to join!\nCreate a new one with `[p]ww new`")
return
await game.join(ctx.author, ctx.channel)
@ww.command()
async def quit(self, ctx):
"""
Quit a game of Werewolf
"""
game = self._get_game(ctx.guild)
await game.quit(ctx.author, ctx.channel)
@ww.command()
async def start(self, ctx):
"""
Checks number of players and attempts to start the game
"""
game = self._get_game(ctx.guild)
if not game:
await ctx.send("No game running, cannot start")
await game.setup(ctx)
@ww.command()
async def vote(self, ctx, id):
"""
Vote for a player by ID
"""
game = self._get_game(ctx.guild)
if not game:
await ctx.send("No game running, cannot vote")
# Game handles response now
channel = ctx.channel
if channel is game.village_channel:
await game.vote(ctx.author, id, channel)
if channel in (c["channel"] for c in game.p_channels.values()):
await game.vote(ctx.author, id, channel)
def _get_game(self, guild, game_code=None):
if guild.id not in self.games:
if not game_code:
return None
self.games[guild.id] = Game(guild, game_code)
return self.games[guild.id]
async def _game_start(self, game):
await game.start()

@ -3,7 +3,7 @@ import discord
from datetime import datetime, timedelta
from random import shuffle
import random
from werewolf.player import Player
@ -18,9 +18,14 @@ class Game:
default_secret_channel = {
"channel": None,
"players": [],
"votegroup": None
"votegroup": None # uninitialized VoteGroup
}
morning_messages = [
"**The sun rises on the village..**",
"**Morning has arrived..**"
]
# def __new__(cls, guild, game_code):
# game_code = ["VanillaWerewolf", "Villager", "Villager"]
@ -28,7 +33,7 @@ class Game:
def __init__(self, guild, game_code):
self.guild = guild
self.game_code = ["Villager"]
self.game_code = ["VanillaWerewolf"]
self.roles = []
@ -45,8 +50,13 @@ class Game:
self.channel_category = None
self.village_channel = None
self.p_channels = {}
self.vote_groups = {}
self.p_channels = {} # uses default_secret_channel
self.vote_groups = {} # ID : VoteGroup()
self.night_results = []
self.loop = asyncio.get_event_loop()
@ -93,18 +103,20 @@ class Game:
self.guild.me: discord.PermissionOverwrite(read_messages=True)
}
for member in self.p_channels[channel_id]["players"]:
overwrite[member] = discord.PermissionOverwrite(read_messages=True)
for player in self.p_channels[channel_id]["players"]:
overwrite[player.member] = discord.PermissionOverwrite(read_messages=True)
channel = await self.guild.create_text_channel(channel_id, overwrites=overwrite, reason="Werewolf secret channel", category=self.channel_category)
channel = await self.guild.create_text_channel(channel_id, overwrites=overwrite, reason="Ww game secret channel", category=self.channel_category)
self.p_channels[channel_id]["channel"] = channel
if self.p_channels[channel_id]["votegroup"] is not None:
vote_group = self.p_channels[channel_id]["votegroup"](self, channel)
await vote_group.register_player()
self.vote_groups[channel_id] = self.p_channels[channel_id]["votegroup"](self, channel)
await vote_group.register_players(*self.p_channels[channel_id]["players"])
self.vote_groups[channel_id] = vote_group
print("Pre-cycle")
await asyncio.sleep(1)
await self._cycle() # Start the loop
@ -126,25 +138,39 @@ class Game:
and repeat with _at_day_start() again
"""
await self._at_day_start()
# Once cycle ends, this will trigger end_game
await self._end_game() # Handle open channels
async def _at_game_start(self): # ID 0
if self.game_over:
return
await self.village_channel.send("Game is starting, please wait for setup to complete")
await self.village_channel.send(embed=discord.Embed(title="Game is starting, please wait for setup to complete"))
await self._notify(0)
async def _at_day_start(self): # ID 1
if self.game_over:
return
await self.village_channel.send("The sun rises on a new day in the village")
embed=discord.Embed(title=random.choice(self.morning_messages))
for result in self.night_results:
embed.add_field(name=result, value="________", inline=False)
await self.village_channel.send(embed=embed)
await self.generate_targets(self.village_channel)
await self.day_perms(self.village_channel)
await self._notify(1)
await self._check_game_over()
if self.game_over:
return
self.can_vote = True
await asyncio.sleep(240) # 4 minute days
await asyncio.sleep(120) # 4 minute days
await self.village_channel.send(embed=discord.Embed(title="**Two minutes of daylight remain...**"))
await asyncio.sleep(120) # 4 minute days
if not self.can_vote or self.game_over:
return
@ -160,7 +186,7 @@ class Game:
self.used_votes += 1
await self.all_but_perms(self.village_channel, target)
await self.village_channel.send("{} will be put to trial and has 30 seconds to defend themselves".format(target.mention))
await self.village_channel.send("**{} will be put to trial and has 30 seconds to defend themselves**".format(target.mention))
await asyncio.sleep(30)
@ -189,7 +215,7 @@ class Game:
await self.village_channel.send(embed=embed)
if len(down_votes) > len(up_votes):
await self.village_channel.send("Voted to lynch {}!".format(target.mention))
await self.village_channel.send("**Voted to lynch {}!**".format(target.mention))
await self.kill(target)
self.can_vote = False
elif self.used_votes >= 3:
@ -211,13 +237,15 @@ class Game:
await self._notify(4, data)
async def _at_day_end(self): # ID 5
await self._check_game_over()
if self.game_over:
return
self.can_vote = False
await self.night_perms(self.village_channel)
await self.village_channel.send("**The sun sets on the village...**")
await self.village_channel.send(embed=discord.Embed(title="**The sun sets on the village...**"))
await self._notify(5)
await asyncio.sleep(30)
@ -252,7 +280,7 @@ class Game:
for role in role_order:
tasks.append(asyncio.ensure_future(role.on_event(event, data), loop=self.loop))
# VoteGroup priorities
vote_order = [votes for votes in self.vote_groups.values() if votes.action_list[event][1]==i]
vote_order = [vg for vg in self.vote_groups.values() if vg.action_list[event][1]==i]
for vote_group in vote_order:
tasks.append(asyncio.ensure_future(vote_group.on_event(event, data), loop=self.loop))
@ -274,7 +302,7 @@ class Game:
return await channel.send(embed=embed)
async def register_channel(self, channel_id, player, votegroup=None):
async def register_channel(self, channel_id, role, votegroup=None):
"""
Queue a channel to be created by game_start
"""
@ -283,7 +311,7 @@ class Game:
await asyncio.sleep(1)
self.p_channels[channel_id]["players"].append(player)
self.p_channels[channel_id]["players"].append(role.player)
if votegroup:
self.p_channels[channel_id]["votegroup"] = votegroup
@ -410,11 +438,18 @@ class Game:
async def assign_roles(self):
"""len(self.roles) must == len(self.players)"""
shuffle(self.roles)
random.shuffle(self.roles)
self.players.sort(key=lambda pl: pl.member.display_name.lower())
if len(self.roles) != len(self.players):
await self.village_channel("Unhandled error - roles!=players")
return False
for idx, role in enumerate(self.roles):
self.roles[idx] = role(self)
await self.roles[idx].assign_player(self.players[idx])
# Sorted players, now assign id's
await self.players[idx].assign_id(idx)
async def get_player_by_member(self, member):
for player in self.players:
@ -444,3 +479,11 @@ class Game:
await channel.set_permissions(self.guild.default_role, read_messages=False)
for member in member_list:
await channel.set_permissions(member, read_messages=True)
async def _check_game_over(self):
#ToDo
pass
async def _end_game(self):
#ToDo
pass

@ -25,5 +25,8 @@ class Player:
role.player = self
self.role = role
async def assign_id(self, id):
self.id = id
async def send_dm(self, message):
await self.member.send(message) # Lets do embeds later

@ -43,11 +43,11 @@ class Role:
allignment = 0 # 1: Town, 2: Werewolf, 3: Neutral
channel_id = "" # Empty for no private channel
unique = False # Only one of this role per game
game_start_message="""
Your role is **Default**
You win by testing the game
Lynch players during the day with `[p]ww lynch <ID>`
"""
game_start_message= (
"Your role is **Default**\n"
"You win by testing the game\n"
"Lynch players during the day with `[p]ww lynch <ID>`"
)
def __init__(self, game):
self.game = game

@ -12,19 +12,18 @@ class VanillaWerewolf(Role):
allignment = 2 # 1: Town, 2: Werewolf, 3: Neutral
channel_id = "werewolves"
unique = False
game_start_message = """
Your role is **Werewolf**
You win by killing everyone else in the village
Lynch players during the day with `[p]ww lynch <ID>`
Vote to kill players at night with `[p]ww vote <ID>`
"""
game_start_message = (
"Your role is **Werewolf**\n"
"You win by killing everyone else in the village\n"
"Lynch players during the day with `[p]ww lynch <ID>`\n"
"Vote to kill players at night with `[p]ww vote <ID>`"
)
def __init__(self, game):
self.game = game
self.player = None
self.blocked = False
self.properties = {} # Extra data for other roles (i.e. arsonist)
super().__init__(game)
self.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_day_start, 0),
@ -32,9 +31,10 @@ class VanillaWerewolf(Role):
(self._at_kill, 0),
(self._at_hang, 0),
(self._at_day_end, 0),
(self._at_night_start, 2),
(self._at_night_start, 2), # Get vote priority
(self._at_night_end, 0)
]
self.killer = None # Added killer
# async def on_event(self, event, data):
# """

@ -9,28 +9,29 @@ class Villager(Role):
allignment = 0 # 1: Town, 2: Werewolf, 3: Neutral
channel_id = "" # Empty for no private channel
unique = False # Only one of this role per game
game_start_message="""
Your role is **Villager**
You win by lynching all evil in the town
Lynch players during the day with `[p]ww lynch <ID>`
"""
game_start_message=(
"Your role is **Villager**\n"
"You win by lynching all evil in the town\n"
"Lynch players during the day with `[p]ww lynch <ID>`\n"
)
def __init__(self, game):
self.game = game
self.player = None
self.blocked = False
self.properties = {} # Extra data for other roles (i.e. arsonist)
super().__init__()
# self.game = game
# self.player = None
# self.blocked = False
# self.properties = {} # Extra data for other roles (i.e. arsonist)
self.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_day_start, 0),
(self._at_voted, 0),
(self._at_kill, 0),
(self._at_hang, 0),
(self._at_day_end, 0),
(self._at_night_start, 0),
(self._at_night_end, 0)
]
# self.action_list = [
# (self._at_game_start, 0), # (Action, Priority)
# (self._at_day_start, 0),
# (self._at_voted, 0),
# (self._at_kill, 0),
# (self._at_hang, 0),
# (self._at_day_end, 0),
# (self._at_night_start, 0),
# (self._at_night_end, 0)
# ]
# async def on_event(self, event, data):
# """

@ -37,10 +37,10 @@ class VoteGroup:
See Game class for event guide
"""
await action_list[event][0](data)
await self.action_list[event][0](data)
async def _at_game_start(self, data=None):
pass
await self.channel.send(" ".join(player.mention for player in self.players))
async def _at_day_start(self, data=None):
pass
@ -79,11 +79,11 @@ class VoteGroup:
# Do what you voted on
pass
async def register_player(self, player):
async def register_players(self, *players):
"""
Add a player to player list
Extend players by passed list
"""
self.players.append(player)
self.players.extend(players)
async def remove_player(self, player):
"""

@ -46,8 +46,7 @@ class WolfVote(VoteGroup):
# await action_list[event][0](data)
# async def _at_game_start(self, data=None):
# if self.channel_id:
# self.channel = await self.game.register_channel(self.channel_id)
# await self.channel.send(" ".join(player.mention for player in self.players))
# async def _at_day_start(self, data=None):
# pass
@ -74,7 +73,7 @@ class WolfVote(VoteGroup):
self.killer = random.choice(self.players)
await channel.send("{} has been selected as tonight's killer")
await self.channel.send("{} has been selected as tonight's killer".format(self.killer.member.display_name))
async def _at_night_end(self, data=None):
if self.channel is None:

Loading…
Cancel
Save