Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ferdinand Schober
Werwolf
Commits
bfccf5bf
Commit
bfccf5bf
authored
Apr 07, 2020
by
Ferdinand Schober
💬
Browse files
asdf
parent
1faac010
Changes
7
Hide whitespace changes
Inline
Side-by-side
__pycache__/game.cpython-38.pyc
View file @
bfccf5bf
No preview for this file type
__pycache__/utility_commands.cpython-38.pyc
View file @
bfccf5bf
No preview for this file type
__pycache__/werewolf_commands.cpython-38.pyc
View file @
bfccf5bf
No preview for this file type
__pycache__/werewolf_roles.cpython-38.pyc
View file @
bfccf5bf
No preview for this file type
bot.py
View file @
bfccf5bf
...
...
@@ -4,12 +4,7 @@ from pprint import pprint
from
discord.ext
import
commands
client
=
commands
.
Bot
(
command_prefix
=
'.'
)
#client.load_extension('village_commands')
client
.
load_extension
(
'werewolf_commands'
)
#client.load_extension('seer_commands')
#client.load_extension('witch_commands')
#client.load_extension('amor_commands')
client
.
load_extension
(
'utility_commands'
)
client
.
run
(
'Njk2MTEyNTQ1MDgxMDY1NTU0.Xoj_iQ.VXMY9AUo56o_k-QgLSUWtPldhjE'
)
\ No newline at end of file
game.py
View file @
bfccf5bf
import
werewolf_roles
import
random
import
random
import
asyncio
async
def
start
(
ctx
,
_players
,
_channels
,
_server_roles
):
global
role
,
players
,
channels
,
server_roles
...
...
@@ -9,13 +10,12 @@ async def start(ctx, _players, _channels, _server_roles):
server_roles
=
_server_roles
await
ctx
.
send
(
f
'starting new game with
{
[
member
.
mention
for
member
in
players
]
}
'
)
await
set_night
()
def
is_alive
(
player
):
return
player
in
players
def
get_role
(
player
):
return
role
[
player
]
l
=
list
()
for
player
in
players
:
l
.
append
(
asyncio
.
create_task
(
player
.
add_roles
([
server_roles
[
'alive'
]])))
for
t
in
l
:
await
t
async
def
check_time_state
():
if
tasks
==
{}:
if
state
==
'day'
:
...
...
@@ -24,19 +24,29 @@ async def check_time_state():
await
set_day
()
async
def
set_night
():
global
state
,
tasks
,
werewolf_votes
global
state
,
tasks
,
werewolf_votes
,
killed
state
=
'night'
tasks
=
{
task
for
task
in
[
tasks
for
tasks
in
[
role
[
player
][
'tasks'
]
for
player
in
players
]]}
werewolf_votes
=
dict
()
await
channels
[
'village_channel'
].
send
(
'Wieder mal wird es dunkel im Düsterwald und das Dorf schläft ein...'
)
killed
=
dict
()
await
channels
[
'village'
].
send
(
'Wieder mal wird es dunkel im Düsterwald und das Dorf schläft ein...'
)
def
check_killed
():
global
killed
tmp
=
killed
.
values
()
for
killed
in
tmp
:
players
.
remove
(
killed
)
return
tmp
async
def
set_day
():
dead
=
await
check_killed
()
await
channels
[
'village'
].
send
(
f
'Das Dorf erwacht ... ohne
{
[
p
.
mention
for
p
in
dead
]
}
'
)
global
state
,
accusations
,
votes
,
tasks
state
=
'day'
accusations
=
set
()
votes
=
dict
()
tasks
=
{
'accusation'
}
await
channels
[
'village
_channel
'
].
send
(
'Das Dorf erwacht...
\n
'
await
channels
[
'village'
].
send
(
'Das Dorf erwacht...
\n
'
'Die Anklage ist eröffnet!
\n
'
'
\n
'
'Um eine Person anzuklagen schreibe $accuse @name!
\n
'
...
...
@@ -91,8 +101,8 @@ async def werewolf_vote(ctx, player):
if
werewolf_votes
.
keys
()
==
{
p
for
p
in
players
if
role
[
p
]
==
werewolf_roles
.
werwolf
}:
#all werewolfs have submitted their vote
if
len
(
set
(
werewolf_votes
.
values
()))
==
1
:
#all votes are equal
tasks
.
remove
(
'werewolfs'
)
global
werewolf_victim
werewolf
_victim
=
list
(
werewolf_votes
.
values
())[
0
]
global
killed
killed
[
'
werewolf
s'
]
=
list
(
werewolf_votes
.
values
())[
0
]
await
notify_werewolf_vote
()
async
def
see
(
ctx
,
player
):
...
...
@@ -105,10 +115,16 @@ async def see(ctx, player):
async
def
heal
(
ctx
,
player
):
if
'heal'
in
tasks
:
global
werewolf_victim
healed
=
werewolf
_victim
werewolf_victim
=
None
global
killed
healed
=
killed
[
'
werewolf
s'
]
del
killed
[
'werewolfs'
]
await
ctx
.
send
(
f
'
{
healed
.
mention
}
wurde geheilt!'
)
tasks
.
remove
(
'heal'
)
async
def
poison
(
ctx
,
player
):
if
'poison'
in
tasks
:
if
player
in
players
:
killed
[
'witch'
]
=
player
async
def
notify_werewolf_vote
():
pass
\ No newline at end of file
werewolf_commands.py
View file @
bfccf5bf
import
asyncio
import
discord
from
discord.ext
import
commands
import
game
...
...
@@ -8,25 +9,29 @@ class Werewolf(commands.Cog):
async
def
log
(
self
,
message
):
print
(
message
)
await
self
.
channels
[
'info
_channel
'
].
send
(
message
)
await
self
.
channels
[
'info'
].
send
(
message
)
@
commands
.
Cog
.
listener
()
async
def
on_ready
(
self
):
self
.
channels
=
{
'welcome
_channel'
:
await
self
.
client
.
fetch_channel
(
696079221684175005
),
'lobby
_channel'
:
await
self
.
client
.
fetch_channel
(
696130304884211733
),
'village
_channel'
:
await
self
.
client
.
fetch_channel
(
696105930336632963
),
'info
_channel'
:
await
self
.
client
.
fetch_channel
(
696130399860162626
),
'werewolf
_channel'
:
await
self
.
client
.
fetch_channel
(
696323465195683891
),
'couple
_channel'
:
await
self
.
client
.
fetch_channel
(
696323604605960213
),
'witch
_channel'
:
await
self
.
client
.
fetch_channel
(
696776678541623336
),
'seer
_channel'
:
await
self
.
client
.
fetch_channel
(
696776695146872872
),
'welcome
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696079221684175005
)
)
,
'lobby
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696130304884211733
)
)
,
'village
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696105930336632963
)
)
,
'info
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696130399860162626
)
)
,
'werewolf
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696323465195683891
)
)
,
'couple
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696323604605960213
)
)
,
'witch
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696776678541623336
)
)
,
'seer
'
:
asyncio
.
create_task
(
self
.
client
.
fetch_channel
(
696776695146872872
)
)
,
}
self
.
server
=
await
self
.
client
.
fetch_guild
(
696079221684175001
)
self
.
server_roles
=
{
'alive'
:
a
wait
self
.
server
.
get_role
(
697048340889731134
),
'dead'
:
a
wait
self
.
server
.
get_role
(
697048466978897990
)
'alive'
:
a
syncio
.
create_task
(
self
.
server
.
get_role
(
697048340889731134
)
)
,
'dead'
:
a
syncio
.
create_task
(
self
.
server
.
get_role
(
697048466978897990
)
)
}
for
v
in
self
.
channels
.
values
():
await
v
for
v
in
self
.
server_roles
.
values
():
await
v
@
commands
.
Cog
.
listener
()
async
def
on_message
(
self
,
message
):
...
...
@@ -39,46 +44,39 @@ class Werewolf(commands.Cog):
@
commands
.
command
()
async
def
start
(
self
,
ctx
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'village_channel'
]:
await
game
.
start
(
ctx
,
set
(
self
.
channels
[
'lobby_channel'
].
members
),
self
.
channels
,
self
.
server_roles
)
if
ctx
.
channel
==
self
.
channels
[
'village'
]:
await
game
.
start
(
ctx
,
set
(
self
.
channels
[
'lobby'
].
members
),
self
.
channels
,
self
.
server_roles
)
@
commands
.
command
()
async
def
accuse
(
self
,
ctx
,
*
,
player
:
discord
.
Member
):
await
ctx
.
message
.
delete
()
if
ctx
.
message
.
channel
==
self
.
channels
[
'village_channel'
]:
if
ctx
.
message
.
channel
==
self
.
channels
[
'village'
]:
await
game
.
accuse
(
ctx
,
player
)
@
commands
.
command
()
async
def
withdraw
(
self
,
ctx
,
*
,
player
:
discord
.
Member
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'village_channel'
]:
if
ctx
.
channel
==
self
.
channels
[
'village'
]:
await
game
.
withdraw
(
ctx
,
player
)
@
commands
.
command
()
async
def
confirm
(
self
,
ctx
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'village_channel'
]:
if
ctx
.
channel
==
self
.
channels
[
'village'
]:
await
game
.
confirm_accusations
(
ctx
)
@
commands
.
command
()
async
def
vote
(
self
,
ctx
,
*
,
player
:
discord
.
Member
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'village_channel'
]:
if
ctx
.
channel
==
self
.
channels
[
'village'
]:
await
game
.
citizen_vote
(
ctx
,
player
)
elif
ctx
.
channel
==
self
.
channels
[
'werewolf
_channel
'
]:
elif
ctx
.
channel
==
self
.
channels
[
'werewolf'
]:
await
game
.
werewolf_vote
(
ctx
,
player
)
@
commands
.
command
()
async
def
see
(
self
,
ctx
,
*
,
player
:
discord
.
Member
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'seer_channel'
]:
if
ctx
.
channel
==
self
.
channels
[
'seer'
]:
await
game
.
see
(
ctx
,
player
)
@
commands
.
command
()
async
def
heal
(
self
,
ctx
,
player
:
discord
.
Member
):
await
ctx
.
message
.
delete
()
if
ctx
.
channel
==
self
.
channels
[
'witch_channel'
]:
if
ctx
.
channel
==
self
.
channels
[
'witch'
]:
await
game
.
heal
(
ctx
,
player
)
@
commands
.
command
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment