Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
D
DARE
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Anzo
DARE
Validations
51512a7c
Valider
51512a7c
rédigé
Il y a 2 ans
par
Enzo De Carvalho Bittencourt
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
v1 done all functionnality
parent
1be4707e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
DARE.py
+316
-67
316 ajouts, 67 suppressions
DARE.py
__pycache__/dice.cpython-311.pyc
+0
-0
0 ajout, 0 suppression
__pycache__/dice.cpython-311.pyc
dice.py
+1
-1
1 ajout, 1 suppression
dice.py
avec
317 ajouts
et
68 suppressions
DARE.py
+
316
−
67
Voir le fichier @
51512a7c
...
...
@@ -6,8 +6,6 @@ import dice
import
codecs
import
copy
"""
import threading
...
...
@@ -49,13 +47,13 @@ class LatencyQueue():
self
.
oneQueue
=
[]
self
.
twoQueue
=
[]
def
add
(
elt
,
index
):
def
add
(
self
,
elt
,
index
):
"""
put elt in the indexQueue
"""
if
index
==
1
:
self
.
oneQueue
.
append
(
elt
)
return
None
elif
index
==
2
:
self
.
one
Queue
.
append
(
elt
)
self
.
two
Queue
.
append
(
elt
)
return
None
else
:
return
None
...
...
@@ -147,8 +145,11 @@ if __name__=="__main__":
S
.
thro
=
[]
S
.
name
=
""
S
.
inroll
=
False
SOld1
=
None
SOld2
=
None
Undoable
=
SimpleNamespace
()
Undoable
.
S
=
S
Undoable
.
OldS
=
S
Undoable
.
RedoS
=
S
#S.PDiceTray.add(SpecialDice(2,"Ψ"))
##INIT CLI
...
...
@@ -164,17 +165,27 @@ if __name__=="__main__":
#This function crash if more than 26 dice are thrown
#This won't ever happen, right ?
i
=
0
sumP
=
0
sumPMax
=
0
sump
=
0
sumpMax
=
0
for
e
in
S
.
PDiceTray
:
print
(
"
\t\033
[38;5;217m
"
+
abc
[
i
]
+
"
\033
[38;5;10m
"
+
e
.
name
+
str
(
e
.
n
)
+
"
[
"
+
"
\033
[0m
"
+
str
(
e
.
value
)
+
"
\033
[38;5;10m]
"
,
end
=
""
)
i
+=
1
sumP
+=
e
.
value
sumPMax
+=
e
.
n
print
(
"
\n
"
,
end
=
""
)
for
e
in
S
.
pDiceTray
:
print
(
"
\t\033
[38;5;217m
"
+
abc
[
i
]
+
"
\033
[38;5;159m
"
+
e
.
name
+
str
(
e
.
n
)
+
"
[
"
+
"
\033
[0m
"
+
str
(
e
.
value
)
+
"
\033
[38;5;159m]
"
,
end
=
""
)
i
+=
1
sump
+=
e
.
value
sumpMax
+=
e
.
n
print
(
"
\033
[0m
"
)
print
(
"
Sum of
\033
[38;5;10m PHI
\033
[0m dice is :
\033
[38;5;217m
"
+
str
(
sumP
)
+
(
"
>
"
if
sumP
>
sumPMax
/
2
else
"
<=
"
)
+
str
(
int
(
sumPMax
/
2
)),
end
=
"
\033
[0m.
\n
"
)
print
(
"
Sum of
\033
[38;5;159m PSI
\033
[0m dice is :
\033
[38;5;217m
"
+
str
(
sump
)
+
(
"
>
"
if
sump
>
sumpMax
/
2
else
"
<=
"
)
+
str
(
int
(
sumpMax
/
2
)),
end
=
"
\033
[0m.
\n
"
)
#Todo : number of same dice
def
printallstat
(
ShowDiceTray
=
False
):
print
(
S
.
name
+
"
:
"
)
def
printallstat
(
S
,
ShowDiceTray
=
False
):
print
(
"
\033
[38;5;214m PHI
\033
[38;5;10m [
"
+
stupidPrint
(
S
.
PHIdicepool
)
+
"
]
\033
[0m
"
,
end
=
""
)
if
not
S
.
PHIqueue
:
print
(
""
)
#list is empty
...
...
@@ -186,7 +197,7 @@ if __name__=="__main__":
else
:
print
(
"
\033
[38;5;67m <
"
+
str
(
S
.
PSIqueue
[
0
])
+
"
\033
[38;5;242m
"
+
stupidPrint
(
S
.
PSIqueue
[
1
:])
+
"
<
\033
[0m
"
)
if
S
.
Latency
.
oneQueue
or
S
.
Latency
.
twoQueue
:
# not empty
print
(
"
\033
[38;5;202 LAT
\033
[38;5;242m 1[
"
+
stupidPrint
(
S
.
Latency
.
oneQueue
)
+
"
] 2[
"
+
stupidPrint
(
S
.
Latency
.
twoQueue
)
+
"
]
"
)
print
(
"
\033
[38;5;202
m
LAT
\033
[38;5;242m 1[
"
+
stupidPrint
(
S
.
Latency
.
oneQueue
)
+
"
] 2[
"
+
stupidPrint
(
S
.
Latency
.
twoQueue
)
+
"
]
"
)
if
ShowDiceTray
:
print
(
"
\033
[38;5;214m ROLL
"
)
...
...
@@ -227,24 +238,34 @@ No command found '"""+str(args[0])+"""'"""
USAGE : move
GM-purposed command.
move the LAT, PSI and PHI queue by one.
"""
S
.
Latency
.
move
()
availDice
=
S
.
Latency
.
move
()
#PHI dice update
if
len
(
S
.
PHIqueue
)
==
1
:
if
len
(
S
.
PHIqueue
)
==
1
:
#one dice control - mainly to not get shenaningans with next "elif"
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
())
elif
S
.
PHIqueue
:
#List not empty
if
S
.
PHIqueue
[
0
]
+
S
.
PHIqueue
[
1
]
<=
8
:
#two first dice are d4
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
())
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
())
if
S
.
PHIqueue
[
0
].
n
+
S
.
PHIqueue
[
1
].
n
<=
8
:
#two first dice are d4
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
(
0
))
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
(
0
))
else
:
S
.
PHIdicepool
.
append
(
S
.
PHIqueue
.
pop
(
0
))
#PSI dice update
if
len
(
S
.
PSIqueue
)
==
1
:
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
())
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
(
0
))
elif
S
.
PSIqueue
:
if
S
.
PSIqueue
[
0
]
+
S
.
PSIqueue
[
1
]
<=
8
:
#two first dice are d4
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
())
if
S
.
PSIqueue
[
0
].
n
+
S
.
PSIqueue
[
1
].
n
<=
8
:
#two first dice are d4
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
(
0
))
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
(
0
))
else
:
S
.
PSIdicepool
.
append
(
S
.
PSIqueue
.
pop
())
#Update queues
for
e
in
availDice
:
if
e
.
name
==
"
Ψ
"
:
S
.
PSIqueue
.
append
(
e
)
else
:
S
.
PHIqueue
.
append
(
e
)
S
.
PSIdicepool
.
sort
()
S
.
PHIdicepool
.
sort
()
return
None
...
...
@@ -252,19 +273,40 @@ move the LAT, PSI and PHI queue by one."""
def
Nothing
(
args
,
S
):
return
None
def
redo
(
args
,
S
):
"""
USAGE : redo
GM-purposed command.
Restore (once) the current state before an undo !
state.
"""
if
Undoable
.
S
==
Undoable
.
RedoS
:
print
(
"""
Nothing to revert !
"""
)
return
None
else
:
Undoable
.
OldS
=
deepcopy
(
Undoable
.
S
)
Undoable
.
S
=
Undoable
.
RedoS
return
None
def
undo
(
args
,
S
):
"""
USAGE : undo
GM-purposed command.
Restore (once) the current state to the previous
state.
"""
if
SOld2
==
S
Old
1
:
if
Undoable
.
S
==
Undoable
.
Old
S
:
print
(
"""
Nothing to revert !
"""
)
return
None
else
:
S
=
SOld2
Undoable
.
RedoS
=
deepcopy
(
Undoable
.
S
)
Undoable
.
S
=
Undoable
.
OldS
##print("Undoable.S =",end="")##DEBUG
##print(Undoable.S)
return
None
def
exitDARE
(
args
,
S
):
...
...
@@ -278,41 +320,12 @@ Closes this programm while being polite :)"""
"""
USAGE : show
all info about the current state.
"""
printallstat
(
S
.
inroll
)
return
None
def
cont
(
args
,
S
):
"""
USAGE : cont
skip a turn.If in a roll, finishes roll.
"""
move
()
print
(
S
.
name
+
"
:
"
)
printallstat
(
S
,
S
.
inroll
)
return
None
def
roll
(
args
,
S
):
"""
USAGE : roll [dices]
Does a roll within the possibilities
of your dice pool, and show the roll
result (with PSI and PHI total sum)
To select a PSI dice, use
"
p
"
as a prefix.
To select a PHI dice, use
"
P
"
as a prefix.
For instance :
roll p4 p4 P6
will roll Ψ4, Ψ4 and Φ6
Once in a roll, you can either
\033
[1m reroll
\033
[0m
up to half of the throw.
dice,
\033
[1m reroll ... add
\033
[0m to add any
dice in your roll,
\033
[1m reroll ... throw
\033
[0m to
remove any dice of your roll, or
\033
[1m cont
\033
[0m to finish
your roll. Please type
\033
[1m help reroll
\033
[0m
To better know how rerolls works in DARE.
LAT, PSI and PHI queues and pool are proprely
updated.
"""
def
add
(
args
,
S
):
"""
add dice into tray
"""
#check for valid input first
if
len
(
args
)
==
0
:
print
(
"
At least one dice is expected.
"
)
...
...
@@ -331,12 +344,14 @@ updated.
# our input are valid !!!
p
=
[]
P
=
[]
addedDice
=
[]
for
d
in
args
:
if
d
[
0
]
==
"
p
"
:
found
=
False
for
e
in
S
.
PSIdicepool
:
if
e
.
n
==
int
(
d
[
1
:]):
S
.
pDiceTray
.
add
(
e
)
addedDice
.
append
(
e
)
S
.
PSIdicepool
.
remove
(
e
)
found
=
True
break
...
...
@@ -354,6 +369,7 @@ updated.
for
e
in
S
.
PHIdicepool
:
if
e
.
n
==
int
(
d
[
1
:]):
S
.
PDiceTray
.
add
(
e
)
addedDice
.
append
(
e
)
S
.
PHIdicepool
.
remove
(
e
)
found
=
True
break
...
...
@@ -365,29 +381,263 @@ updated.
S
.
pDiceTray
.
tray
=
[]
S
.
PDiceTray
.
tray
=
[]
return
None
return
addedDice
def
deepcopy
(
S
):
SCopy
=
copy
.
deepcopy
(
S
)
SCopy
.
PHIdicepool
=
copy
.
deepcopy
(
S
.
PHIdicepool
)
SCopy
.
PSIdicepool
=
copy
.
deepcopy
(
S
.
PSIdicepool
)
SCopy
.
PDiceTray
=
copy
.
deepcopy
(
S
.
PDiceTray
)
SCopy
.
pDiceTray
=
copy
.
deepcopy
(
S
.
pDiceTray
)
SCopy
.
Latency
=
copy
.
deepcopy
(
S
.
Latency
)
SCopy
.
PHIqueue
=
copy
.
deepcopy
(
S
.
PHIqueue
)
SCopy
.
PSIqueue
=
copy
.
deepcopy
(
S
.
PSIqueue
)
SCopy
.
thro
=
copy
.
deepcopy
(
S
.
thro
)
SCopy
.
inroll
=
S
.
inroll
##DEBUG##print("Copy :",end="")
##print(SCopy)
return
SCopy
def
roll
(
args
,
S
):
"""
USAGE : roll [dices]
Does a roll within the possibilities
of your dice pool, and show the roll
result (with PSI and PHI total sum)
To select a PSI dice, use
"
p
"
as a prefix.
To select a PHI dice, use
"
P
"
as a prefix.
For instance :
roll p4 p4 P6
will roll Ψ4, Ψ4 and Φ6
Once in a roll, you can either
\033
[1m reroll
\033
[0m
up to half of the throw.
dice,
\033
[1m reroll ... add
\033
[0m to add any
dice in your roll,
\033
[1m reroll ... throw
\033
[0m to
remove any dice of your roll, or
\033
[1m cont
\033
[0m to finish
your roll. Please type
\033
[1m help reroll
\033
[0m
To better know how rerolls works in DARE.
LAT, PSI and PHI queues and pool are proprely
updated.
"""
##UNDO MGMT
Undoable
.
OldS
=
deepcopy
(
Undoable
.
S
)
add
(
args
,
S
)
S
.
pDiceTray
.
tray
.
sort
()
S
.
PDiceTray
.
tray
.
sort
()
S
.
pDiceTray
.
rollall
()
S
.
PDiceTray
.
rollall
()
#State : in roll
S
.
inroll
=
True
print
(
str
(
S
.
name
)
+
"
does a roll !
"
)
printDiceTray
()
printallstat
(
S
,
S
.
inroll
)
return
None
def
reroll
(
args
,
S
):
"""
USAGE : reroll [dice] [throw [dice]] [add [dice]]
reroll dice.
Additionnally, you can add any dice of your pool
with the add keyword, or throw any dice of your
current tray with the throw keyword.
For instance, consider this roll :
Ninten:
PHI [ Φ4 Φ4 Φ6 Φ6 ]
PSI [ Ψ4 Ψ4 Ψ8 ]
ROLL
aΦ4[3] bΦ6[1]
cΨ4[3] dΨ6[4]
Sum of PHI dice is : 4 <= 5.
Sum of PSI dice is : 7 > 5.
One could then type :
reroll ac throw b add p4
This would :
reroll a and c dice,
throw the b dice
add a psi4 dice into the final roll
if you only want to add or throw dice,
you can type
reroll add ...
reroll throw ...
reroll throw add...
The ordering of the keywords doesn
'
t matter.
"""
#UNDO MGMT
Undoable
.
OldS
=
deepcopy
(
Undoable
.
S
)
if
not
(
S
.
inroll
):
print
(
"""
Must start a roll first ! see
\033
[1m help roll
\033
[0m for
more info
"""
)
return
None
if
len
(
args
)
==
0
:
print
(
"
For usage see
\033
[1m help reroll
\033
[0m .
"
)
return
None
doAdd
=
False
doThrow
=
False
addIndex
=
-
1
throwIndex
=
-
1
addList
=
[]
throwList
=
[]
rerollList
=
args
if
args
.
count
(
"
add
"
)
>
1
:
print
(
"
Too much
'
add
'
keyword. see
\033
[1m help reroll
\033
[0m to see
\n
correct formatting
"
)
return
None
if
args
.
count
(
"
throw
"
)
>
1
:
print
(
"
Too much
'
throw
'
keyword. see
\033
[1m help reroll
\033
[0m to see\ n correct formatting
"
)
return
None
if
"
add
"
in
args
:
doAdd
=
True
addIndex
=
args
.
index
(
"
add
"
)
addList
=
args
[
addIndex
+
1
:]
rerollList
=
rerollList
[:
addIndex
]
if
"
throw
"
in
args
:
doThrow
=
True
throwIndex
=
args
.
index
(
"
throw
"
)
throwList
=
args
[
throwIndex
+
1
:]
rerollList
=
rerollList
[:
throwIndex
]
##After these two if, rerollList is OK,
##But it is certain that either "throw" or "add" appears in each other.
if
"
add
"
in
throwList
:
throwList
=
throwList
[:
throwList
.
index
(
"
add
"
)]
if
"
throw
"
in
addList
:
addList
=
addList
[:
addList
.
index
(
"
throw
"
)]
index
=
0
diceDict
=
{}
for
e
in
S
.
PDiceTray
.
tray
:
diceDict
[
abc
[
index
]]
=
e
index
+=
1
for
a
in
S
.
pDiceTray
.
tray
:
diceDict
[
abc
[
index
]]
=
a
index
+=
1
if
doAdd
and
addList
:
addedDice
=
add
(
addList
,
S
)
if
not
addedDice
:
return
None
allstrThrow
=
""
if
len
(
throwList
)
>
1
:
for
letters
in
throwList
:
allstrThrow
=
allstrThrow
+
letters
elif
throwList
:
allstrThrow
=
throwList
[
0
]
allstr
=
""
if
len
(
rerollList
)
>
1
:
for
letters
in
rerollList
:
allstr
=
allstr
+
letters
elif
rerollList
:
allstr
=
rerollList
[
0
]
for
c
in
allstr
+
allstrThrow
:
if
not
(
c
in
diceDict
):
print
(
"
no dice of index
'"
+
c
+
"'
!
"
)
return
None
numDice
=
len
(
S
.
PDiceTray
.
tray
)
+
len
(
S
.
pDiceTray
.
tray
)
if
len
(
allstr
)
>
numDice
:
#Should never happen
print
(
"""
Cannot reroll this much dice !
You can at most reroll half of your dice.
Here, it would mean at most
"""
+
str
(
numDice
//
2
)
+
"""
dice.
"""
)
return
None
##TODO Moar checking
##Now, everything should be okay !
if
doThrow
:
for
l
in
allstrThrow
:
S
.
thro
.
append
(
diceDict
[
l
])
if
diceDict
[
l
]
in
S
.
pDiceTray
:
S
.
pDiceTray
.
tray
.
remove
(
diceDict
[
l
])
else
:
S
.
PDiceTray
.
tray
.
remove
(
diceDict
[
l
])
if
doAdd
:
for
dice
in
addedDice
:
dice
.
roll
()
for
l
in
allstr
:
diceDict
[
l
].
roll
()
print
(
S
.
name
+
"
rerolls !
"
)
printallstat
(
S
,
True
)
print
(
"
the roll is over.
"
)
cont
(
"
[žInvokedFromRR]
"
,
S
)
return
None
def
cont
(
args
,
S
):
"""
USAGE : cont
Skips a turn. If done during a roll,
said roll is finished.
"""
if
not
args
or
not
(
args
[
0
]
in
[
"
žInvokedFromRR
"
,
"
žInvokedFromTrash
"
]):
#UNDO MGMT
Undoable
.
OldS
=
deepcopy
(
Undoable
.
S
)
S
.
inroll
=
False
if
not
args
or
args
[
0
]
!=
"
žInvokedFromTrash
"
:
move
(
""
,
S
)
all
=
S
.
pDiceTray
.
tray
+
S
.
PDiceTray
.
tray
+
S
.
thro
all
.
sort
()
for
e
in
all
:
e
.
reset
()
if
e
.
n
<
5
:
if
e
.
name
==
"
Ψ
"
:
S
.
PSIqueue
.
append
(
e
)
else
:
S
.
PHIqueue
.
append
(
e
)
elif
e
.
n
<
10
:
S
.
Latency
.
add
(
e
,
1
)
else
:
S
.
Latency
.
add
(
e
,
2
)
S
.
pDiceTray
.
tray
=
[]
S
.
PDiceTray
.
tray
=
[]
S
.
thro
=
[]
if
args
and
args
[
0
]
==
"
žInvokedFromRR
"
:
return
None
printallstat
(
S
)
return
None
def
trash
(
args
,
S
):
"""
USAGE : trash [dice]
GM-purposed command.
Trash dice as if they were rolled
"""
Undoable
.
OldS
=
deepcopy
(
Undoable
.
S
)
add
(
args
,
S
)
cont
([
"
žInvokedFromTrash
"
],
S
)
return
None
COMMAND_LIST
=
{
"
exit
"
:
exitDARE
,
"
quit
"
:
exitDARE
,
"
help
"
:
helpDARE
,
"
show
"
:
show
,
"
undo
"
:
undo
,
"
redo
"
:
Nothing
,
"
move
"
:
move
,
"
redo
"
:
redo
,
"
roll
"
:
roll
,
"
cont
"
:
Nothing
,
"
reroll
"
:
Nothing
,
"
t
hrow
"
:
Nothing
,
"
cont
"
:
cont
,
"
reroll
"
:
reroll
,
"
t
rash
"
:
trash
,
}
## get init param :
...
...
@@ -427,7 +677,7 @@ Please give your PSI dice pool
S
.
PSIdicepool
.
sort
()
line
()
printallstat
()
printallstat
(
S
)
print
(
"
\n
Welcome
"
+
S
.
name
+
"
!
"
)
print
(
"""
...
...
@@ -437,18 +687,17 @@ To get an explanation of a command"""
)
line
()
##Main While Command
SOld1
=
S
#error
while
True
:
SOld2
=
copy
.
deepcopy
(
SOld1
)
#undo mgmt
##print("Undoable.S =",end="")##DEBUG
##print(Undoable.S)
uinput
=
ask
(
"
command?
"
)
SOld1
=
copy
.
deepcopy
(
S
)
#undo mgmt
args
=
uinput
.
split
(
"
"
)
if
args
[
0
]
in
COMMAND_LIST
:
COMMAND_LIST
[
args
[
0
]](
args
[
1
:],
S
)
if
args
[
0
]
in
COMMAND_LIST
:
COMMAND_LIST
[
args
[
0
]](
args
[
1
:],
Undoable
.
S
)
elif
args
[
0
]
!=
""
:
print
(
"""
No command found
'"""
+
str
(
args
[
0
])
+
"""'
try
\033
[1mhelp
\033
[0m to see command list.
"""
try
\033
[1mhelp
\033
[0m to see command list.
"""
#+str(Undoable.SOld.PHIdicepool)
)
line
()
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
__pycache__/dice.cpython-311.pyc
+
0
−
0
Voir le fichier @
51512a7c
Aucun aperçu pour ce type de fichier
Ce diff est replié.
Cliquez pour l'agrandir.
dice.py
+
1
−
1
Voir le fichier @
51512a7c
...
...
@@ -65,7 +65,7 @@ class DiceTray:
return
self
.
tray
.
pop
(
index
)
def
add
(
self
,
dice
):
self
.
tray
.
append
(
copy
.
deepcopy
(
dice
.
reset
())
)
self
.
tray
.
append
(
dice
)
return
self
def
__iter__
(
self
):
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter