Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Story overhaul #75

Merged
merged 26 commits into from
Mar 1, 2018
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
786821e
Testing story mode
agraubert Jan 10, 2018
adfb144
Added basic story implimentation
agraubert Jan 10, 2018
678e22a
Story mode gets priority on message recognition
agraubert Jan 10, 2018
45af9db
Added separate story channel
agraubert Jan 10, 2018
eb093ca
Beymax will now delete other messages in the channel
agraubert Jan 10, 2018
255ad28
Added balance and fixed score
agraubert Jan 10, 2018
e4c4b28
Syntax error
agraubert Jan 10, 2018
7df7172
Merge branch 'config' into story
agraubert Jan 28, 2018
c1fd516
Updated story to use channel references
agraubert Jan 28, 2018
848f74a
Merge branch 'master' into story
agraubert Feb 1, 2018
c8f1647
XP now runs from level 2
agraubert Feb 1, 2018
67c8815
Added XP system
agraubert Feb 8, 2018
745f172
Working on story XP
agraubert Feb 20, 2018
e29f4e2
Refactored database to be async safe
agraubert Feb 21, 2018
236849a
Fixed database synchronization
agraubert Feb 21, 2018
9764d9d
Finished XP backend
agraubert Feb 21, 2018
d63775d
Finished economy implementation
agraubert Feb 21, 2018
53fca7e
Fixed up economy implementation
agraubert Feb 21, 2018
df75fe3
Added quoting
agraubert Feb 21, 2018
1ae5dd2
Merge pull request #66 from agraubert/economy
agraubert Feb 23, 2018
f5a2e0d
Added simple exception handling when failing to deliver a message
agraubert Feb 23, 2018
3aeecee
Added highscore and timeleft
agraubert Feb 23, 2018
a49d7d6
Reup now simply adds a day instead of being dumb
agraubert Feb 23, 2018
1b78b4f
Various fixes
agraubert Feb 27, 2018
b2ce378
Fixed more recognition in player
agraubert Feb 27, 2018
6068fce
Added dfrotz and games to install.md
agraubert Feb 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added balance and fixed score
  • Loading branch information
agraubert committed Jan 10, 2018
commit 255ad289329f5e2e2c6f5cb0d50aa704e91c95fb
48 changes: 47 additions & 1 deletion bots/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def EnableStory(bot):

@bot.add_command('!_stories')
async def cmd_story(self, message, content):
"""
`!_stories` : Lists the available stories
"""
games = [
f[:-3] for f in os.listdir('games') if f.endswith('.z5')
]
Expand Down Expand Up @@ -160,6 +163,8 @@ async def state_router(self, message, content):
'```'+self.player.readchunk()+'```'
)
elif content == 'score':
self.player.write('score')
self.player.readchunk()
await self.send_message(
message.channel,
'Your score is %d' % self.player.score
Expand All @@ -171,6 +176,7 @@ async def state_router(self, message, content):
'You have quit your game. Your score was %d' % self.player.score
)
state['user'] = '~<IDLE>'
del state['transcript']
del self.player
save_db(state, 'game.json')
else:
Expand All @@ -182,15 +188,20 @@ async def state_router(self, message, content):
'```'+self.player.readchunk()+'```'
)
else:
await self.delete_message(message)
await self.send_message(
message.author,
"Please refrain from posting messages in the story channel"
" while someone else is playing"
)
await asyncio.sleep(0.5)
await self.delete_message(message)

@bot.add_command('!_start')
async def cmd_start(self, message, content):
"""
`!_start <game name>` : Starts an interactive text adventure
Example: `!_start zork1`
"""
state = load_db('game.json', {'user':'~<IDLE>'})
if state['user'] == '~<IDLE>':
games = {
Expand Down Expand Up @@ -244,3 +255,38 @@ async def cmd_start(self, message, content):


return bot

def xp_for(level):
if level <= 1:
return 10
else:
return (2*xp_for(level-1)-xp_for(level-2))+5

@bot.add_command('!_balance')
async def cmd_balance(self, message, content):
"""
`!_balance` : Displays your current token balance
"""
players = load_db('players.json')
if message.author.id not in players:
players[message.author.id] = {
'level':1,
'xp':0,
'balance':10
}
player = players[message.author.id]
await self.send_message(
message.channel,
"You are currently level %d and have a balance of %d tokens\n"
"You have %d xp to go to reach the next level" % (
player['level'],
player['balance'],
xp_for(player['level']+1)-player['xp']
)
)

@bot.add_command('!_bid')
async def cmd_bid(self, message, content):
"""
`!_bid <amount> <game>` : Place a bid to play the next game
"""