From fe35f3b63dc9348105ab9c104dc7b04aaf508637 Mon Sep 17 00:00:00 2001 From: tcaxle Date: Sat, 11 Apr 2020 15:15:05 +0100 Subject: [PATCH] rollConfiguration. Migrations. 2 --- app/__pycache__/models.cpython-38.pyc | Bin 12919 -> 12697 bytes app/migrations/0012_auto_20200411_1414.py | 64 +++++++++++++++++ .../0012_auto_20200411_1414.cpython-38.pyc | Bin 0 -> 1432 bytes app/models.py | 65 ++++++++---------- 4 files changed, 91 insertions(+), 38 deletions(-) create mode 100644 app/migrations/0012_auto_20200411_1414.py create mode 100644 app/migrations/__pycache__/0012_auto_20200411_1414.cpython-38.pyc diff --git a/app/__pycache__/models.cpython-38.pyc b/app/__pycache__/models.cpython-38.pyc index 94927ca01509eade6c76c219c1b8b649211f3ca5..85f5562f922a56a9434e88f92fd590e82be1f8e4 100644 GIT binary patch delta 4959 zcmaJ^TTEQX8Q!z(eU}9T=3>Cc7YxhI1mCcYxtN==xtU$ZWKF=!&M_>kSv)vN|g4VW!pa=_HGIxux9tz0nsSUs3})i{-hF}LnS9FSV`8U6xL2iYM|hf->VU=FiJFpU^g1Vh`v9AQVn98EFBV2-gSFimPP zMw9>_XU)LP5|;wEuvXw!iMIo{u@k^2QWkcAX`g2upgPnYFi{4glXU@iNxT!do1Fwc zsqRGoF5n(^3iy=7yMa%$Uf^Cieh+XT>j&;nxhMxSzy`q#rkK58&afdcLz2P#D?oXf z50o!8s1nRs_Bfcw)k-+_0H0&Sz{3((0YAa~!2Xm*HJI~k1k8w94UHP$C)p_QsKm9v zW9$O(1+@nKb-)2OzG!f>aY^iBMz6sWeDqUehqXMvb9k_Kprfb1d#t0!+cr4Z*){}l zwXpN4*>Hq~W+uw^l|8C(bSdWJ*ijD!cb+~%EiH3wEEo<%qd_$s9vkBw;F975wK_>0 zgm{1_YJ{*U{GeE>%o7(JHR6zKYX4!7KHdl!`g;aOA4Q8FBhgGknvqteE%NyT@u{n( zs*8HlxjT)H@8el^cY4KLDD&(|a@Qr@aR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tuyFwu`dG(nUarhE{*m}-YEDPMDXqMb zGR0}{d3Qse8eI_6y%#roGOo8EmrC-@*EXMAs@lHOd}S{AcbC!MRaREkB`$8R|37B} BHsAmN diff --git a/app/migrations/0012_auto_20200411_1414.py b/app/migrations/0012_auto_20200411_1414.py new file mode 100644 index 0000000..8486c03 --- /dev/null +++ b/app/migrations/0012_auto_20200411_1414.py @@ -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'), + ), + ] diff --git a/app/migrations/__pycache__/0012_auto_20200411_1414.cpython-38.pyc b/app/migrations/__pycache__/0012_auto_20200411_1414.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4f6a6c3625482f5a5aa00c49a45efbfbaef8d468 GIT binary patch literal 1432 zcmcJPOK;Oa5Xb$@!%ZorP|7=$rwioO^d+IvM?zJpq*c>MC#6!9)OQde%uqOc)=49X_~6e4$&k8)E1u`cLpjJ#0OMXGge%Qr*YbAvYX zogEV>R`3drML{5Z<)#FpB{pTEbX1T)CW%h6lL7@)NI()&mI`T01Pw+Y1EWVOTsS&q z$A+>OVSIqSG?bly%LD9{q3k4F9bl)1ve)4H0DEI7dlPOAu(!`)@9;Wg;qCxCJ(Rr% z_XpSqL)nM$Xn=iu9t*l9;cm>plT+H#nrV27J@AaCU!Cr~E>YR+_2^`wP%Ik0=QwT8 z-M6i%-x|&Fe_T}d3q^cPscqM)Xg!ypO4b|e>(zQ4CsDgif&hJq%64OItBQ9oYB`LW ztiIma+OBNYHjK(S4%MisI**A>V(99$m< zd?`0SSMmp5m*hjQo6lKxm?wuOt_6AApZwqBBagjPGR!FSj8dUgD3r02isfQC*L&}? zVzHcq4w{rK{Zdp#l<=25`Cqf?6XhF!udX&Vj5OCzx1W0&I;LxRIcV|XaPDuy{n-l) Tm8PEeE4<7y2w2@xVn+TAD#UL{ literal 0 HcmV?d00001 diff --git a/app/models.py b/app/models.py index 32933f2..9a60fed 100644 --- a/app/models.py +++ b/app/models.py @@ -155,8 +155,7 @@ DIE_TYPES = [ ("NONE", "None"), ("SUCCESS", "Success"), ("DOUBLE", "Double"), - ("EXPLODING", "Exploding"), - ("DISAPPEARING", "Disappearing"), + ("EXPLODING_DISAPPEARING", "Exploding / Disappearing"), ("SUBTRACTING", "Subtracting") ] @@ -215,7 +214,7 @@ class NamedCharField(models.CharField): kwargs['max_length'] = 100 super().__init__(*args, **kwargs) -class DieField(models.CharField): +class DieField(multiselectfield.MultiSelectField): def __init__(self, verbose_name, number, default, *args, **kwargs): self.number = number kwargs['verbose_name'] = verbose_name @@ -234,18 +233,18 @@ class DieField(models.CharField): #-------------------------------- DICE ROLLING --------------------------------# #==============================================================================# class rollConfiguration(models.Model): - r01 = DieField("1s", 1, "NONE") - r02 = DieField("2s", 2, "NONE") - r03 = DieField("3s", 3, "NONE") - r04 = DieField("4s", 4, "NONE") - r05 = DieField("5s", 5, "NONE") - r06 = DieField("6s", 6, "NONE") - r07 = DieField("7s", 7, "SUCCESS") - r08 = DieField("8s", 8, "SUCCESS") - r09 = DieField("9s", 9, "SUCCESS") - r10 = DieField("10s", 10, "DOUBLE") + r01 = DieField("1s", 1, ["NONE"]) + r02 = DieField("2s", 2, ["NONE"]) + r03 = DieField("3s", 3, ["NONE"]) + r04 = DieField("4s", 4, ["NONE"]) + r05 = DieField("5s", 5, ["NONE"]) + r06 = DieField("6s", 6, ["NONE"]) + r07 = DieField("7s", 7, ["SUCCESS"]) + r08 = DieField("8s", 8, ["SUCCESS"]) + r09 = DieField("9s", 9, ["SUCCESS"]) + r10 = DieField("10s", 10, ["SUCCESS", "DOUBLE"]) - def listDice(self): + def roll(self, pool=1): listDice = [ self.r01, self.r02, @@ -260,24 +259,17 @@ class rollConfiguration(models.Model): ] listSuccess = [] listDouble = [] - listExploding = [] - listDisappearing = [] + listExplodingDisappearing = [] listSubtracting = [] for die in listDice: - if die == "SUCCESS": + if "SUCCESS" in die: listSuccess.append(die.number) - elif die == "DOUBLE": + if "DOUBLE" in die: listDouble.append(die.number) - elif die == "EXPLODING": - listExploding.append(die.number) - elif die == "DISAPPEARING": - listDisappearing.append(die.number) - elif die == "SUBTRACTING": + if "EXPLODING_DISAPPEARING" in die: + listExplodingDisappearing.append(die.number) + if "SUBTRACTING" in die: listSubtracting.append(die.number) - return listSuccess, listDouble, listExploding, listDisappearing, listSubtracting - - def roll(self, pool=1): - listSuccess, listDouble, listExploding, listDisappearing, listSubtracting = self.listDice() successes = 0 listExploded, listDisappeared = [], [] listRoll = [0 for die in range(pool)] @@ -285,27 +277,24 @@ class rollConfiguration(models.Model): for die in listRoll: if die == 0: die = randint(1, 10) - if die in listExploding: - listExploded.append(die) - die = 0 - if die in listDisappearing: - listDisappeared.append(die) + if die in listExplodingDisappearing: + if die in listSuccess: + listExploded.append(die) + else: + listDisappeared.append(die) die = 0 for die in listRoll + listExploded: if die in listSuccess: successes += 1 - elif die in listDouble: - successes += 2 - elif die in listSubtracting: + if die in listDouble: + successes += 1 + if die in listSubtracting: successes -= 1 if successes < 0: successes = 0 botch = (successes == 0) and (1 in listRoll) return successes, botch, listRoll, listExploded, listDisappeared - - - #==============================================================================# #--------------------------------- MODIFIERS ----------------------------------# #==============================================================================#