rollConfiguration. Migrations. 2
This commit is contained in:
parent
0b9ac811ee
commit
fe35f3b63d
Binary file not shown.
64
app/migrations/0012_auto_20200411_1414.py
Normal file
64
app/migrations/0012_auto_20200411_1414.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# Generated by Django 3.0.5 on 2020-04-11 14:14
|
||||||
|
|
||||||
|
import app.models
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('app', '0011_rollconfiguration'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r01',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=1, verbose_name='1s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r02',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=2, verbose_name='2s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r03',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=3, verbose_name='3s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r04',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=4, verbose_name='4s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r05',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=5, verbose_name='5s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r06',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['NONE'], max_length=100, number=6, verbose_name='6s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r07',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['SUCCESS'], max_length=100, number=7, verbose_name='7s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r08',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['SUCCESS'], max_length=100, number=8, verbose_name='8s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r09',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['SUCCESS'], max_length=100, number=9, verbose_name='9s'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rollconfiguration',
|
||||||
|
name='r10',
|
||||||
|
field=app.models.DieField(choices=[('NONE', 'None'), ('SUCCESS', 'Success'), ('DOUBLE', 'Double'), ('EXPLODING_DISAPPEARING', 'Exploding / Disappearing'), ('SUBTRACTING', 'Subtracting')], default=['SUCCESS', 'DOUBLE'], max_length=100, number=10, verbose_name='10s'),
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
@ -155,8 +155,7 @@ DIE_TYPES = [
|
|||||||
("NONE", "None"),
|
("NONE", "None"),
|
||||||
("SUCCESS", "Success"),
|
("SUCCESS", "Success"),
|
||||||
("DOUBLE", "Double"),
|
("DOUBLE", "Double"),
|
||||||
("EXPLODING", "Exploding"),
|
("EXPLODING_DISAPPEARING", "Exploding / Disappearing"),
|
||||||
("DISAPPEARING", "Disappearing"),
|
|
||||||
("SUBTRACTING", "Subtracting")
|
("SUBTRACTING", "Subtracting")
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -215,7 +214,7 @@ class NamedCharField(models.CharField):
|
|||||||
kwargs['max_length'] = 100
|
kwargs['max_length'] = 100
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
class DieField(models.CharField):
|
class DieField(multiselectfield.MultiSelectField):
|
||||||
def __init__(self, verbose_name, number, default, *args, **kwargs):
|
def __init__(self, verbose_name, number, default, *args, **kwargs):
|
||||||
self.number = number
|
self.number = number
|
||||||
kwargs['verbose_name'] = verbose_name
|
kwargs['verbose_name'] = verbose_name
|
||||||
@ -234,18 +233,18 @@ class DieField(models.CharField):
|
|||||||
#-------------------------------- DICE ROLLING --------------------------------#
|
#-------------------------------- DICE ROLLING --------------------------------#
|
||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
class rollConfiguration(models.Model):
|
class rollConfiguration(models.Model):
|
||||||
r01 = DieField("1s", 1, "NONE")
|
r01 = DieField("1s", 1, ["NONE"])
|
||||||
r02 = DieField("2s", 2, "NONE")
|
r02 = DieField("2s", 2, ["NONE"])
|
||||||
r03 = DieField("3s", 3, "NONE")
|
r03 = DieField("3s", 3, ["NONE"])
|
||||||
r04 = DieField("4s", 4, "NONE")
|
r04 = DieField("4s", 4, ["NONE"])
|
||||||
r05 = DieField("5s", 5, "NONE")
|
r05 = DieField("5s", 5, ["NONE"])
|
||||||
r06 = DieField("6s", 6, "NONE")
|
r06 = DieField("6s", 6, ["NONE"])
|
||||||
r07 = DieField("7s", 7, "SUCCESS")
|
r07 = DieField("7s", 7, ["SUCCESS"])
|
||||||
r08 = DieField("8s", 8, "SUCCESS")
|
r08 = DieField("8s", 8, ["SUCCESS"])
|
||||||
r09 = DieField("9s", 9, "SUCCESS")
|
r09 = DieField("9s", 9, ["SUCCESS"])
|
||||||
r10 = DieField("10s", 10, "DOUBLE")
|
r10 = DieField("10s", 10, ["SUCCESS", "DOUBLE"])
|
||||||
|
|
||||||
def listDice(self):
|
def roll(self, pool=1):
|
||||||
listDice = [
|
listDice = [
|
||||||
self.r01,
|
self.r01,
|
||||||
self.r02,
|
self.r02,
|
||||||
@ -260,24 +259,17 @@ class rollConfiguration(models.Model):
|
|||||||
]
|
]
|
||||||
listSuccess = []
|
listSuccess = []
|
||||||
listDouble = []
|
listDouble = []
|
||||||
listExploding = []
|
listExplodingDisappearing = []
|
||||||
listDisappearing = []
|
|
||||||
listSubtracting = []
|
listSubtracting = []
|
||||||
for die in listDice:
|
for die in listDice:
|
||||||
if die == "SUCCESS":
|
if "SUCCESS" in die:
|
||||||
listSuccess.append(die.number)
|
listSuccess.append(die.number)
|
||||||
elif die == "DOUBLE":
|
if "DOUBLE" in die:
|
||||||
listDouble.append(die.number)
|
listDouble.append(die.number)
|
||||||
elif die == "EXPLODING":
|
if "EXPLODING_DISAPPEARING" in die:
|
||||||
listExploding.append(die.number)
|
listExplodingDisappearing.append(die.number)
|
||||||
elif die == "DISAPPEARING":
|
if "SUBTRACTING" in die:
|
||||||
listDisappearing.append(die.number)
|
|
||||||
elif die == "SUBTRACTING":
|
|
||||||
listSubtracting.append(die.number)
|
listSubtracting.append(die.number)
|
||||||
return listSuccess, listDouble, listExploding, listDisappearing, listSubtracting
|
|
||||||
|
|
||||||
def roll(self, pool=1):
|
|
||||||
listSuccess, listDouble, listExploding, listDisappearing, listSubtracting = self.listDice()
|
|
||||||
successes = 0
|
successes = 0
|
||||||
listExploded, listDisappeared = [], []
|
listExploded, listDisappeared = [], []
|
||||||
listRoll = [0 for die in range(pool)]
|
listRoll = [0 for die in range(pool)]
|
||||||
@ -285,27 +277,24 @@ class rollConfiguration(models.Model):
|
|||||||
for die in listRoll:
|
for die in listRoll:
|
||||||
if die == 0:
|
if die == 0:
|
||||||
die = randint(1, 10)
|
die = randint(1, 10)
|
||||||
if die in listExploding:
|
if die in listExplodingDisappearing:
|
||||||
|
if die in listSuccess:
|
||||||
listExploded.append(die)
|
listExploded.append(die)
|
||||||
die = 0
|
else:
|
||||||
if die in listDisappearing:
|
|
||||||
listDisappeared.append(die)
|
listDisappeared.append(die)
|
||||||
die = 0
|
die = 0
|
||||||
for die in listRoll + listExploded:
|
for die in listRoll + listExploded:
|
||||||
if die in listSuccess:
|
if die in listSuccess:
|
||||||
successes += 1
|
successes += 1
|
||||||
elif die in listDouble:
|
if die in listDouble:
|
||||||
successes += 2
|
successes += 1
|
||||||
elif die in listSubtracting:
|
if die in listSubtracting:
|
||||||
successes -= 1
|
successes -= 1
|
||||||
if successes < 0:
|
if successes < 0:
|
||||||
successes = 0
|
successes = 0
|
||||||
botch = (successes == 0) and (1 in listRoll)
|
botch = (successes == 0) and (1 in listRoll)
|
||||||
return successes, botch, listRoll, listExploded, listDisappeared
|
return successes, botch, listRoll, listExploded, listDisappeared
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
#--------------------------------- MODIFIERS ----------------------------------#
|
#--------------------------------- MODIFIERS ----------------------------------#
|
||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
|
Loading…
Reference in New Issue
Block a user