Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
discordbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3c3cad9f
authored
2016-02-25 06:47:26 +0000
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Basic pankration added with arena.
1 parent
8ccecd68
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
4 deletions
data.py
db.sqlite3
hellsbot.py
pankration.py
data.py
View file @
3c3cad9
...
...
@@ -337,9 +337,74 @@ def db_remove_reflector(member_id, idx):
WHERE member_id = ?;"""
,
(
pickle
.
dumps
(
reflectors
),
member_id
))
conn
.
commit
()
def
db_convert_soul_plate_to_reflector
(
member_id
,
soul_plate
,
idx
):
db_add_reflector
(
member_id
,
soul_plate
)
db_remove_soul_plate
(
member_id
,
idx
)
if
not
db_add_reflector
(
member_id
,
soul_plate
):
return
False
if
not
db_remove_soul_plate
(
member_id
,
idx
):
return
False
return
True
def
db_register_battle
(
member_id
,
reflector
,
idx
,
target_member
=
None
):
pan_record
=
db_get_pankration_record
(
member_id
)
conn
=
sqlite3
.
connect
(
'db.sqlite3'
)
c
=
conn
.
cursor
()
db_state
=
c
.
execute
(
"SELECT battle_id, reflector_primary member_id FROM pankration_arena WHERE battle_status = 'waiting';"
)
.
fetchall
()
if
not
db_state
:
log
(
"No battles available: {}"
.
format
(
idx
,))
c
.
execute
(
"""INSERT INTO pankration_arena(primary_member_id, reflector_primary)
VALUES(?, ?);"""
,
(
member_id
,
pickle
.
dumps
(
reflector
)))
conn
.
commit
()
conn
.
close
()
db_remove_reflector
(
member_id
,
idx
)
else
:
for
row
in
db_state
:
primary_reflector
=
pickle
.
loads
(
str
(
row
[
1
]))
primary_level
=
primary_reflector
.
level
# TODO: Setup challenges based on level difference of no more than 10 or spawn a new monster.
# if primary_level - 10 <= reflector.level <= primary_level + 10:
battle_id
=
row
[
0
]
c
.
execute
(
"""UPDATE pankration_arena SET secondary_member_id = ?, reflector_secondary = ?, battle_status = 'queued', queue_start = ?
WHERE battle_id = ?;"""
,
(
member_id
,
pickle
.
dumps
(
reflector
),
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
),
battle_id
))
conn
.
commit
()
conn
.
close
()
db_remove_reflector
(
member_id
,
idx
)
return
def
db_complete_battle
(
battle_id
,
primary_member_id
,
primary_reflector
,
secondary_member_id
,
secondary_reflector
):
pass
def
db_start_battle
(
battle_id
):
conn
=
sqlite3
.
connect
(
'db.sqlite3'
)
c
=
conn
.
cursor
()
c
.
execute
(
"""UPDATE pankration_arena SET battle_status = 'fighting', battle_start = ?
WHERE battle_id = ?;"""
,
(
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
),
battle_id
))
conn
.
commit
()
conn
.
close
()
def
db_get_battle_queue
():
conn
=
sqlite3
.
connect
(
'db.sqlite3'
)
c
=
conn
.
cursor
()
result
=
c
.
execute
(
"SELECT * FROM pankration_arena WHERE battle_status = 'queued' ORDER BY queue_start;"
)
.
fetchall
()
conn
.
close
()
results
=
[]
for
row
in
result
:
results
.
append
(
dict_factory
(
c
,
row
))
return
results
def
db_get_member_username
(
member_id
):
# Do a lookup by ID, if it's found but the name doesn't match then add a row to aliases with the previous name and change the member name
member_conn
=
sqlite3
.
connect
(
'db.sqlite3'
)
c
=
member_conn
.
cursor
()
result
=
c
.
execute
(
"SELECT member_name FROM members WHERE member_id = ?;"
,
(
member_id
,))
.
fetchone
()
member_conn
.
close
()
return
result
[
0
]
def
db_get_member
(
discord_id
=
None
,
username
=
None
):
...
...
db.sqlite3
View file @
3c3cad9
No preview for this file type
hellsbot.py
View file @
3c3cad9
This diff is collapsed.
Click to expand it.
pankration.py
View file @
3c3cad9
...
...
@@ -365,10 +365,10 @@ class Monster:
break
def
get_current_posture
(
self
):
return
TemperamentPosture
(
self
.
temperament_posture
)
return
TemperamentPosture
[
self
.
temperament_posture
]
def
get_current_attitude
(
self
):
return
TemperamentAttitude
(
self
.
temperament_attitude
)
return
TemperamentAttitude
[
self
.
temperament_attitude
]
def
get_dicipline_level
(
self
):
if
self
.
dicipline_level
<
2
:
...
...
Please
register
or
sign in
to post a comment