mirror of
https://github.com/wr34k/IRCUFC.git
synced 2024-12-22 05:36:37 +00:00
bugfix, strike nerf, better logic
This commit is contained in:
parent
69c7f0de1f
commit
005a6cfbed
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random, json, os
|
||||
import random, json, os, time
|
||||
|
||||
from fighter import Fighter
|
||||
|
||||
@ -177,19 +177,19 @@ class Fight(object):
|
||||
if f.stance == e.stance == 'ground':
|
||||
dmg = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['dmgidx']
|
||||
mindmg = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['mindmg']
|
||||
blockidx = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['blockidx']
|
||||
fallchance = 0
|
||||
texts = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['text']
|
||||
missluck = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['missluck']
|
||||
texts = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance][e.groundPos]['text']
|
||||
else:
|
||||
dmg = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['dmgidx']
|
||||
mindmg = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['mindmg']
|
||||
blockidx = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['blockidx']
|
||||
fallchance = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['fallchance'] \
|
||||
if 'fallchance' in self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance] \
|
||||
else 0
|
||||
texts = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['text']
|
||||
missluck = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['missluck']
|
||||
texts = self.config['moves'][f.stance][f.nextAction[0]][f.nextAction[1]][e.stance]['text']
|
||||
|
||||
return dmg, mindmg, blockidx, fallchance, texts
|
||||
return dmg, mindmg, fallchance, missluck, texts
|
||||
|
||||
def attack(self):
|
||||
roll1 = roll2 = 0
|
||||
@ -228,7 +228,7 @@ class Fight(object):
|
||||
if attacker.groundPos == 'below':
|
||||
attacker.groundPos = 'above'
|
||||
defender.groundPos = 'below'
|
||||
self.shout("{} Manage to get above {}!".format( \
|
||||
self.shout("{} manages to get above {}!".format( \
|
||||
self.IRC.mirc.color(attacker.nick, attacker.colour), \
|
||||
self.IRC.mirc.color(defender.nick, defender.colour) \
|
||||
))
|
||||
@ -236,10 +236,11 @@ class Fight(object):
|
||||
if attacker.nextAction[0] == 'standup':
|
||||
standchance = self.config['moves'][attacker.stance]['standup'][defender.stance]['chance']
|
||||
else:
|
||||
dmg, mindmg, blockidx, fallchance, texts = self.get_next_move_data(attacker, defender)
|
||||
dmg, mindmg, fallchance, missluck, texts = self.get_next_move_data(attacker, defender)
|
||||
|
||||
realdmg = (random.random() * dmg) + mindmg
|
||||
|
||||
txt = self.prettyTxt(attacker, defender, texts)
|
||||
self.shout("{}".format(txt))
|
||||
|
||||
blockchance = 0
|
||||
if defender.nextAction[0] == 'block':
|
||||
@ -248,26 +249,32 @@ class Fight(object):
|
||||
blocktxts = self.config["moves"][defender.stance][defender.nextAction[0]][defender.nextAction[1]]["text"]
|
||||
|
||||
|
||||
if (random.random() * 100) < blockchance * (blockidx / 100):
|
||||
blocktxt = self.prettyTxt(attacker, defender, blocktxts)
|
||||
self.shout("{}".format(blocktxt))
|
||||
if (random.random() * 100) < blockchance:
|
||||
blocktxt = self.prettyTxt(attacker, defender, blocktxts)
|
||||
self.shout("{}".format(txt))
|
||||
self.shout("{}".format(blocktxt))
|
||||
else:
|
||||
if defender.nextAction[0] == 'block':
|
||||
self.shout("{} Tryed to block {} but failed miserably!".format(self.IRC.mirc.color(defender.nick, defender.colour), defender.nextAction[1]))
|
||||
if (random.random()*100) < missluck:
|
||||
self.shout("{}".format(txt))
|
||||
self.shout("{} failed to hit {}!".format(self.IRC.mirc.color(attacker.nick, attacker.colour), self.IRC.mirc.color(defender.nick, defender.colour)))
|
||||
defender.advantage = True
|
||||
attacker.advantage = False
|
||||
else:
|
||||
txt += " | (- {} hp)".format(self.IRC.mirc.color(int(realdmg), self.IRC.mirc.colors.YELLOW))
|
||||
self.shout("{}".format(txt))
|
||||
if defender.nextAction[0] == 'block':
|
||||
self.shout("{} tried to block {} but failed miserably!".format(self.IRC.mirc.color(defender.nick, defender.colour), defender.nextAction[1]))
|
||||
|
||||
defender.hp -= realdmg
|
||||
|
||||
realdmg = (random.random() * dmg) + mindmg
|
||||
|
||||
defender.hp -= realdmg
|
||||
|
||||
if (random.random() * 100) < fallchance: # defender falls down?
|
||||
defender.stance = 'ground'
|
||||
if attacker.stance == 'ground':
|
||||
defender.groundPos = 'above'
|
||||
else:
|
||||
defender.groundPos = 'below'
|
||||
falltxt = self.prettyTxt(attacker, defender, self.config['info']['stand2ground'])
|
||||
self.shout("{}".format(falltxt))
|
||||
if (random.random() * 100) < fallchance: # defender falls down?
|
||||
defender.stance = 'ground'
|
||||
if attacker.stance == 'ground':
|
||||
defender.groundPos = 'above'
|
||||
else:
|
||||
defender.groundPos = 'below'
|
||||
falltxt = self.prettyTxt(attacker, defender, self.config['info']['stand2ground'])
|
||||
self.shout("{}".format(falltxt))
|
||||
|
||||
|
||||
if defender.hp <= 0:
|
||||
@ -304,15 +311,20 @@ class Fight(object):
|
||||
self.IRC.privmsg(self.IRC.channel, msg)
|
||||
|
||||
def updatePalmares(self, winner, looser):
|
||||
if not os.path.isfile(PALMARES_FILE):
|
||||
open(PALMARES_FILE, "x").close()
|
||||
|
||||
mode = "r" if os.path.exists(PALMARES_FILE) else "w+"
|
||||
with open(PALMARES_FILE, mode) as f:
|
||||
with open(PALMARES_FILE, "r") as f:
|
||||
try:
|
||||
palmares = json.loads(f.read())
|
||||
data = f.read()
|
||||
palmares = {}
|
||||
if data:
|
||||
palmares = json.loads(data)
|
||||
except Exception as e:
|
||||
self.IRC.log.error("Error in json.loads() backuping palmares file to {}.bkp".format(PALMARES_FILE), e)
|
||||
tNow = int(time.time())
|
||||
self.IRC.log.error("Error in json.loads() backuping palmares file to {}.{}.bkp".format(PALMARES_FILE, tNow), e)
|
||||
from shutil import copyfile
|
||||
copyfile(PALMARES_FILE, "{}.bkp".format(PALMARES_FILE))
|
||||
copyfile(PALMARES_FILE, "{}.{}.bkp".format(PALMARES_FILE, tNow))
|
||||
palmares = {}
|
||||
|
||||
if winner.nick not in palmares:
|
||||
|
39
README.md
39
README.md
@ -1,5 +1,5 @@
|
||||
# IRCUFC
|
||||
WORK IN PROGRESS
|
||||
**WORK IN PROGRESS**
|
||||
|
||||
IRC Game to let chatters having UFC like fights.
|
||||
|
||||
@ -7,32 +7,31 @@ IRC Game to let chatters having UFC like fights.
|
||||
Connect to #IRCUFC @ Efnet and type !fight to register to the next fight
|
||||
|
||||
|
||||
once 2 fighters will be registered, you'll reveice a list of actions possible for you to do in the next turn.
|
||||
|
||||
To register an action for the next turn, simply use !action following by the action (ex: !action kick high)
|
||||
once 2 fighters will be registered, you'll reveice a list of actions possible for you to do in the next turn. (kick high, punch middle, ...)
|
||||
|
||||
Once a fighter have no hp left, the fight is over.
|
||||
|
||||
|
||||
### How to run:
|
||||
|
||||
```
|
||||
python3 main.py
|
||||
```
|
||||
|
||||
### General Commands:
|
||||
* **!fight** -- Register for the next fight
|
||||
* **!status** -- Get current status of the fight (If sent as PM to the bot, you'll get more information like your next move)
|
||||
* **!action** -- Register your next action (ex: !action kick high, !action block middle, !action standup)
|
||||
|
||||
### Admin Commands:
|
||||
* **!cancel** -- Cancel the current fight
|
||||
|
||||
|
||||
If both fighters are attacking at the same time, then the one who will hit is random. There's still an slight advantage to the last player having hit.
|
||||
|
||||
using 'block' will greatly increase the chance of blocking a hit. be careful though, if for instance you block high and your opponent attacks you low or middle, you'll have 100% chance of taking the hit. If you succeed to block a hit, you'll take the advantage for the next turn.
|
||||
|
||||
|
||||
There's a chance for fighters to fall down. In this case, hits will be much less powerful, and your opponent will do huge damage. You'll have to use the 'standup' action in order to .. stand up :) This action will make you vulnerable to a hit.
|
||||
|
||||
|
||||
TODO LIST:
|
||||
Fix shitty code (!!!)
|
||||
Add better output (Colors, formatting)
|
||||
Add submissions
|
||||
Add more strikes? (Superman punch, spinning kicks)
|
||||
Add ascii art to display at each turn
|
||||
|
||||
IDEAS:
|
||||
Add a betting system, where spectators can bet for the next fight
|
||||
Add XP system, where each fight let you get stronger / more resistant / get more moves
|
||||
### More Info:
|
||||
If both fighters are attacking at the same time, then the one who will hit is random. There's still an slight advantage to the last player having hit. Also, some attacks have more chance to fail, but those ones are usually more powerful.
|
||||
|
||||
Using 'block' with the right level (high, middle, low) will give you a great chance to block the next hit. If so, you won't loose HP, and you'll take the advantage for the next round.. Be careful though, if for instance you block high and your opponent attacks you low or middle, you'll have 100% chance of taking the hit (Except if the strike fails). Blocking chance depend on your stance.
|
||||
|
||||
There's a chance for fighters to fall down. In this case, hits will be much less powerful, and your opponent will do huge damage. If both fighters are on the ground, then one of them will be above the other. (The second fighter to fall will be above. Then, the one with the advantage will be above.) You'll have to use the '**!action standup**' command in order to .. stand up :)
|
||||
|
8
TODO
Normal file
8
TODO
Normal file
@ -0,0 +1,8 @@
|
||||
TODO LIST:
|
||||
Add submissions
|
||||
Fix shitty code (!!!)
|
||||
Add ascii art to display at each turn
|
||||
Add better output (Colors, formatting)
|
||||
Add more strikes? (Superman punch, spinning kicks)
|
||||
Add a betting system, where spectators can bet for the next fight
|
||||
Add XP system, where each fight let you get stronger / more resistant / get more moves (??)
|
@ -21,18 +21,18 @@
|
||||
"kick": {
|
||||
"high": {
|
||||
"stand": {
|
||||
"dmgidx": 40,
|
||||
"dmgidx": 30,
|
||||
"mindmg": 20,
|
||||
"fallchance": 5,
|
||||
"blockidx": 50,
|
||||
"missluck": 30,
|
||||
"text": [
|
||||
"%attacker% head kicks %defender%"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"dmgidx": 60,
|
||||
"dmgidx": 45,
|
||||
"mindmg": 25,
|
||||
"blockidx": 28,
|
||||
"missluck": 20,
|
||||
"text": [
|
||||
"%attacker% stomps %defender% in the head!"
|
||||
]
|
||||
@ -40,18 +40,18 @@
|
||||
},
|
||||
"middle": {
|
||||
"stand": {
|
||||
"dmgidx": 30,
|
||||
"dmgidx": 20,
|
||||
"mindmg": 10,
|
||||
"fallchance": 8,
|
||||
"blockidx": 38,
|
||||
"missluck": 20,
|
||||
"text": [
|
||||
"%attacker% middle kicks %defender%"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"dmgidx": 45,
|
||||
"dmgidx": 30,
|
||||
"mindmg": 20,
|
||||
"blockidx": 32,
|
||||
"missluck": 10,
|
||||
"text": [
|
||||
"%attacker% stomps %defender% in the body!"
|
||||
]
|
||||
@ -59,18 +59,18 @@
|
||||
},
|
||||
"low": {
|
||||
"stand": {
|
||||
"dmgidx": 23,
|
||||
"dmgidx": 13,
|
||||
"mindmg": 5,
|
||||
"fallchance": 15,
|
||||
"blockidx": 35,
|
||||
"missluck": 22,
|
||||
"text": [
|
||||
"%attacker% low kicks %defender%"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"dmgidx": 30,
|
||||
"mindmg": 15,
|
||||
"blockidx": 40,
|
||||
"dmgidx": 10,
|
||||
"mindmg": 5,
|
||||
"missluck": 12,
|
||||
"text": [
|
||||
"%attacker% kicks %defender%'s legs while %defender% is on the ground"
|
||||
]
|
||||
@ -80,10 +80,10 @@
|
||||
"punch": {
|
||||
"high": {
|
||||
"stand": {
|
||||
"dmgidx": 30,
|
||||
"mindmg": 10,
|
||||
"dmgidx": 18,
|
||||
"mindmg": 12,
|
||||
"fallchance": 2,
|
||||
"blockidx": 30,
|
||||
"missluck": 25,
|
||||
"text": [
|
||||
"%attacker% head punches %defender%"
|
||||
]
|
||||
@ -91,10 +91,10 @@
|
||||
},
|
||||
"middle": {
|
||||
"stand": {
|
||||
"dmgidx": 20,
|
||||
"mindmg": 5,
|
||||
"dmgidx": 10,
|
||||
"mindmg": 6,
|
||||
"fallchance": 4,
|
||||
"blockidx": 21,
|
||||
"missluck": 10,
|
||||
"text": [
|
||||
"%attacker% punches %defender% to the body"
|
||||
]
|
||||
@ -139,27 +139,27 @@
|
||||
"kick": {
|
||||
"high": {
|
||||
"stand": {
|
||||
"dmgidx": 30,
|
||||
"dmgidx": 15,
|
||||
"mindmg": 10,
|
||||
"fallchance": 8,
|
||||
"blockidx": 58,
|
||||
"missluck": 40,
|
||||
"text": [
|
||||
"%attacker% head kicks %defender% from the ground!"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"above": {
|
||||
"dmgidx": 20,
|
||||
"mindmg": 11,
|
||||
"blockidx": 66,
|
||||
"dmgidx": 10,
|
||||
"mindmg": 14,
|
||||
"missluck": 30,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with kneel kicks to the head from below"
|
||||
]
|
||||
},
|
||||
"below": {
|
||||
"dmgidx": 40,
|
||||
"mindmg": 23,
|
||||
"blockidx": 42,
|
||||
"dmgidx": 25,
|
||||
"mindmg": 20,
|
||||
"missluck": 15,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with huge kneel kicks to the head!"
|
||||
]
|
||||
@ -168,27 +168,27 @@
|
||||
},
|
||||
"middle": {
|
||||
"stand": {
|
||||
"dmgidx": 20,
|
||||
"mindmg": 5,
|
||||
"dmgidx": 12,
|
||||
"mindmg": 8,
|
||||
"fallchance": 5,
|
||||
"blockidx": 43,
|
||||
"missluck": 33,
|
||||
"text": [
|
||||
"%attacker% middle kicks %defender% from the ground!"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"above": {
|
||||
"dmgidx": 13,
|
||||
"mindmg": 9,
|
||||
"blockidx": 70,
|
||||
"dmgidx": 8,
|
||||
"mindmg": 3,
|
||||
"missluck": 26,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with kneel kicks to the body for below"
|
||||
]
|
||||
},
|
||||
"below": {
|
||||
"dmgidx": 25,
|
||||
"mindmg": 17,
|
||||
"blockidx": 48,
|
||||
"dmgidx": 18,
|
||||
"mindmg": 15,
|
||||
"missluck": 12,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with kneel kicks to the body"
|
||||
]
|
||||
@ -197,27 +197,27 @@
|
||||
},
|
||||
"low": {
|
||||
"stand": {
|
||||
"dmgidx": 15,
|
||||
"mindmg": 3,
|
||||
"fallchance": 18,
|
||||
"blockidx": 33,
|
||||
"dmgidx": 8,
|
||||
"mindmg": 1,
|
||||
"fallchance": 28,
|
||||
"missluck": 12,
|
||||
"text": [
|
||||
"%attacker% low kicks %defender% from the ground!"
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"above": {
|
||||
"dmgidx": 7,
|
||||
"mindmg": 2,
|
||||
"blockidx": 65,
|
||||
"dmgidx": 4,
|
||||
"mindmg": 1,
|
||||
"missluck": 22,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with kneel kicks to the legs from below"
|
||||
]
|
||||
},
|
||||
"below": {
|
||||
"dmgidx": 15,
|
||||
"mindmg": 2,
|
||||
"blockidx": 40,
|
||||
"dmgidx": 12,
|
||||
"mindmg": 8,
|
||||
"missluck": 8,
|
||||
"text": [
|
||||
"%attacker% hit %defender% with kneel kicks to the legs"
|
||||
]
|
||||
|
@ -1 +1 @@
|
||||
{"wr34k": {"wins": 1, "looses": 0}, "wreek": {"wins": 0, "looses": 1}}
|
||||
{"wreek": {"wins": 2, "looses": 0}, "wr34k": {"wins": 0, "looses": 2}}
|
@ -89,7 +89,7 @@ class IrcBot(object):
|
||||
data = self.sock.recv(1024).decode('utf-8', 'ignore')
|
||||
|
||||
for line in [x.split() for x in data.split("\r\n") if len(x.split()) > 1]:
|
||||
self.log.info("<< {}".format(' '.join(line)))
|
||||
# self.log.info("<< {}".format(' '.join(line)))
|
||||
|
||||
if line[0][1:] == 'ING':
|
||||
ircEvents.eventPING(self, line)
|
||||
|
@ -74,7 +74,7 @@ class IrcCommands(object):
|
||||
if chan != self.IRC.channel:
|
||||
self.fight.set_next_action(nick, args)
|
||||
else:
|
||||
self.IRC.privmsg(self.IRC.channel, "{}".format(self.IRC.mirc.color("Not here retard your opponent can see your next move!", self.IRC.mirc.colors.LIGHTRED)))
|
||||
self.IRC.privmsg(self.IRC.channel, "{}".format(self.IRC.mirc.color("Not here retard your opponent can see your next move!", self.IRC.mirc.colors.PURPLE)))
|
||||
|
||||
|
||||
self.IRC.flood_flag[chan] = False
|
||||
|
Loading…
Reference in New Issue
Block a user