@solly_ucko/

UnconsciousOddInitializationfile

Python

No description

fork
loading
Files
  • main.py
  • user_passwords.dbm

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.505460148416774","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJhbmRvbQppbXBvcnQgdGltZQppbXBvcnQgc3lzCgppbXBvcnQgZGJtCmZyb20gZnVuY3Rvb2xzIGltcG9ydCB3cmFwcwpmcm9tIGdldHBhc3MgaW1wb3J0IGdldHBhc3MKZnJvbSB0eXBpbmcgaW1wb3J0IEFueSwgQ2FsbGFibGUsIE11dGFibGVNYXBwaW5nLCBUeXBlVmFyCmZyb20gd2Vya3pldWcgaW1wb3J0IGdlbmVyYXRlX3Bhc3N3b3JkX2hhc2gsIGNoZWNrX3Bhc3N3b3JkX2hhc2gKCgp1c2VyczogTXV0YWJsZU1hcHBpbmdbc3RyLCBzdHJdID0gZGJtLm9wZW4oJ3VzZXJfcGFzc3dvcmRzLmRibScsICdjJykKCgpUID0gVHlwZVZhcignVCcpCgoKZGVmIGl0ZXJhdGVfdW50aWxfY29uZGl0aW9uKGNvbmRpdGlvbjogQ2FsbGFibGVbW1RdLCBBbnldID0gYm9vbCkgLT4gQ2FsbGFibGVbW0NhbGxhYmxlWy4uLiwgVF1dLCBDYWxsYWJsZVsuLi4sIFRdXToKICAgIGRlZiBkZWNvcmF0b3IoZjogQ2FsbGFibGVbLi4uLCBUXSkgLT4gQ2FsbGFibGVbLi4uLCBUXToKICAgICAgICBAd3JhcHMoZikKICAgICAgICBkZWYgd3JhcHBlZCgqYXJncywgKiprd2FyZ3MpOgogICAgICAgICAgICByZXN1bHQgPSBmKCphcmdzLCAqKmt3YXJncykKCiAgICAgICAgICAgIHdoaWxlIG5vdCBjb25kaXRpb24ocmVzdWx0KToKICAgICAgICAgICAgICAgIHJlc3VsdCA9IGYoKmFyZ3MsICoqa3dhcmdzKQogICAgICAgICAgICAKICAgICAgICAgICAgcmV0dXJu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GFzcygnUGFzc3dvcmQ6ICcpCgogICAgICAgIGlmIHVzZXJuYW1lIG5vdCBpbiB1c2VyczoKICAgICAgICAgICAgcHJpbnQoJ0luY29ycmVjdCB1c2VybmFtZS4nKQoKICAgICAgICBpZiBub3QgY2hlY2tfcGFzc3dvcmRfaGFzaCh1c2Vyc1t1c2VybmFtZV0sIHBhc3N3b3JkKToKICAgICAgICAgICAgcHJpbnQoJ0luY29ycmVjdCBwYXNzd29yZC4nKQogICAgICAgIAogICAgICAgIHJldHVybiB1c2VybmFtZQogICAgZWxzZToKICAgICAgICByZXR1cm4gTm9uZQoKCmRlZiBtYWluKCk6CiAgICBwcmludCgiKioqKioqKioqKioqKioqKipXZWxjb21lIFRvIFRoZSBESUNFIEdhbWUqKioqKioqKioqKioqKioqKioqIikKCiAgICAjIHVzZXIgPSBpbnRlcmFjdGl2ZV9sb2dpbigpOiBwYXNzCgogICAgcGxheWVyXzEgPSAwCiAgICBwbGF5ZXJfMiA9IDAKCiAgICB0b3RhbF9zY29yZV8xID0gMAogICAgdG90YWxfc2NvcmVfMiA9IDAKCgoKICAgICNwbGF5ZXIgMQoKICAgIGRpZV8xID0gcmFuZG9tLnJhbmRpbnQoMSw2KQogICAgZGllXzIgPSByYW5kb20ucmFuZGludCgxLDYpCiAgICByb3VuZG5vID0gMQogICAgd2hpbGUgcm91bmRubyA8IDU6CiAgICAgICAgdG90YWxfc2NvcmVfMT10b3RhbF9zY29yZV8xK3BsYXllcl8xCiAgICAgICAgdG90YWxfc2NvcmVfMj10b3RhbF9zY29yZV8yK3BsYXllcl8yCiAgICAgICAgcGxheWVyXzE9ZGllXzErZGllXzIKICAgICAgICByb3VuZG5vPXJvdW5kbm8rMQogICAgICAgIHByaW50KCJyb3VuZCIscm91bmRubykKICAgICAgICB0aW1lLnNsZWVwKDEpCiAgICAgICAgcHJpbnQoIi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIikKICAgICAgICBhc2RmID0gaW5wdXQoInBsYXllciAxLCBwcmVzcyBlbnRlciB0byByb2xsIikKICAgICAgICBwcmludCgicGxheWVyIDEgaXMgcm9sbGluZyIpCiAgICAgICAgcHJpbnQoInBsYXllciAxJ3MgZmlyc3Qgcm9sbCBpcyIsZGllXzEpCiAgICAgICAgdGltZS5zbGVlcCgxKQogICAgICAgIHByaW50KCJwbGF5ZXIgMSdzIHNlY29uZCByb2xsIGlzIixkaWVfMikKICAgICAgICB0aW1lLnNsZWVwKDEpCiAgICAgICAgcHJpbnQoIi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIikKICAgICAgICBpZiBwbGF5ZXJfMSAlMj09MDoKICAgICAgICAgICAgcHJpbnQoIlRoaXMgaXMgYW4gZXZlbiBudW1iZXIuIHNvICsxMCBwb2ludHMiKQogICAgICAgICAgICB0aW1lLnNsZWVwKDEpCiAgICAgICAgICAgIHBsYXllcl8xPXBsYXllcl8xKzEwCiAgICAgICAgICAgIHRpbWUuc2xlZXAoMSkKICAgICAgICAgICAgcHJpbnQoInNjb3JlIGlzIixwbGF5ZXJfMSkKICAgICAgICAgICAgaWYgcGxheWVyXzE8PSAwOgogICAgICAgICAgICAgICAgcHJpbnQoInlvdSBoYXZlIGxvc3QgdGhlIGdhbWUiKQogICAgICAgICAgICAgICAgc3lzLmV4aXQoKQogICAgICAgICAgICBwcmludCgiLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0iKQoKICAgICAgICBlbHNlOgogICAgICAgICAgICBwcmludCgiVGhpcyBpcyBhbiBvZGQgbnVtYmVyLiIpCiAgICAgICAgICAgIHRpbWUuc2xlZXAoMikKICAgICAgICAgICAgcGxheWVyXzE9cGxheWVyXzEtNQogICAgICAgICAgICBwcmludCgic2NvcmUgaXMiLHBsYXllcl8xKQogICAgICAgICAgICB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pCgogICAgICAgIGlmIHBsYXllcl8yICUyPT0wOgogICAgICAgICAgICBwcmludCgiVGhpcyBpcyBhbiBldmVuIG51bWJlci4gc28gKzEwIHBvaW50cyIpCiAgICAgICAgICAgIHRpbWUuc2xlZXAoMSkKICAgICAgICAgICAgcGxheWVyXzI9cGxheWVyXzIrMTAKICAgICAgICAgICAgcHJpbnQoInNjb3JlIGlzIixwbGF5ZXJfMikKICAgICAgICAgICAgdGltZS5zbGVlcCgxKQogICAgICAgICAgICBpZiBwbGF5ZXJfMjw9IDA6CiAgICAgICAgICAgICAgICBwcmludCgieW91IGhhdmUgbG9zdCB0aGUgZ2FtZSIpCiAgICAgICAgICAgICAgICBzeXMuZXhpdCgpCiAgICAgICAgICAgIHByaW50KCItLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSIpCgogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHByaW50KCJUaGlzIGlzIGFuIG9kZCBudW1iZXIuIikKICAgICAgICAgICAgdGltZS5zbGVlcCgxKQogICAgICAgICAgICBwbGF5ZXJfMj1wbGF5ZXJfMi01CiAgICAgICAgICAgIHByaW50KCJzY29yZSBpcyIscGxheWVyXzIpCiAgICAgICAgICAgIHRpbWUuc2xlZXAoMykKICAgICAgICAgICAgcHJpbnQoInBsYXllciAyIHNjb3JlIixwbGF5ZXJfMikKICAgICAgICAgICAgcHJpbnQoIi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIikKCiAgICBwcmludCgidGhlIHRvdGFsIHNjb3JlIGZvciBwbGF5ZXIgMSBpcyAiLHRvdGFsX3Njb3JlXzEpCiAgICBwcmludCgidGhlIHRvdGFsIHNjb3JlIGZvciBwbGF5ZXIgMiBpcyAiLHRvdGFsX3Njb3JlXzIpCiAgICBpZiB0b3RhbF9zY29yZV8xID4gdG90YWxfc2NvcmVfMjoKICAgICAgICBwcmludCgicGxheWVyIDEgd2lucyIpCiAgICAgICAgZmlsZSA9IG9wZW4oInNjb3Jlcy50eHQyIiwiYSsiKQogICAgICAgIGZpbGUud3JpdGUoInBsYXllciAxICIpCiAgICAgICAgZmlsZS53cml0ZSh1c2VybmFtZTEpCiAgICAgICAgZmlsZS53cml0ZSgiIGhhcyB3b24gb3ZlcmFsbCB3aXRoICIpCiAgICAgICAgZmlsZS53cml0ZShzdHIodG90YWxfc2NvcmVfMSkpCiAgICAgICAgZmlsZS53cml0ZSgiIHBvaW50cyIpCiAgICAgICAgZmlsZS53cml0ZSgiXG4iKQoKICAgIGlmIHRvdGFsX3Njb3JlXzIgPiB0b3RhbF9zY29yZV8xOgogICAgICAgIHByaW50KCJwbGF5ZXIgMiB3aW5zIikKICAgICAgICBmaWxlID0gb3Blbigic2NvcmVzLnR4dDIiLCJhKyIpCiAgICAgICAgZmlsZS53cml0ZSgicGxheWVyIDIgIikKICAgICAgICBmaWxlLndyaXRlKHVzZXJuYW1lMikKICAgICAgICBmaWxlLndyaXRlKCIgaGFzIHdvbiBvdmVyYWxsIHdpdGggIikKICAgICAgICBmaWxlLndyaXRlKHN0cih0b3RhbF9zY29yZV8yKSkKICAgICAgICBmaWxlLndyaXRlKCIgcG9pbnRzIikKICAgICAgICBmaWxlLndyaXRlKCJcbiIpICAgICAKCgppZiBfX25hbWVfXyA9PSAnX19tYWluX18nOgogICAgbWFpbigpCg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import random
import time
import sys

import dbm
from functools import wraps
from getpass import getpass
from typing import Any, Callable, MutableMapping, TypeVar
from werkzeug import generate_password_hash, check_password_hash


users: MutableMapping[str, str] = dbm.open('user_passwords.dbm', 'c')


T = TypeVar('T')


def iterate_until_condition(condition: Callable[[T], Any] = bool) -> Callable[[Callable[..., T]], Callable[..., T]]:
    def decorator(f: Callable[..., T]) -> Callable[..., T]:
        @wraps(f)
        def wrapped(*args, **kwargs):
            result = f(*args, **kwargs)

            while not condition(result):
                result = f(*args, **kwargs)
            
            return result
        return wrapped
    return decorator


@iterate_until_condition()
def interactive_login():
    choice = input('New user ("n") or existing user ("e")? ').lower()

    if choice.startswith('n'):
        username = input('Username: ')
        password = getpass('Password: ')
        confirmation_password = getpass('Confirm password: ')

        if password != confirmation_password:
            print('Passwords do not match. Account not created.')
            return None
        
        if username in users:
            print('Username already in use. Account not created.')
            return None

        users[username] = generate_password_hash(password)

        print(f'Logged in as {username}.')

        return username
    elif choice.startswith('e'):
        username = input('Username: ')
        password = getpass('Password: ')

        if username not in users:
            print('Incorrect username.')

        if not check_password_hash(users[username], password):
            print('Incorrect password.')
        
        return username
    else:
        return None


def main():
    print("*****************Welcome To The DICE Game*******************")

    # user = interactive_login(): pass

    player_1 = 0
    player_2 = 0

    total_score_1 = 0
    total_score_2 = 0



    #player 1

    die_1 = random.randint(1,6)
    die_2 = random.randint(1,6)
    roundno = 1
    while roundno < 5:
        total_score_1=total_score_1+player_1
        total_score_2=total_score_2+player_2
        player_1=die_1+die_2
        roundno=roundno+1
        print("round",roundno)
        time.sleep(1)
        print("-----------------------------------------------------")
        asdf = input("player 1, press enter to roll")
        print("player 1 is rolling")
        print("player 1's first roll is",die_1)
        time.sleep(1)
        print("player 1's second roll is",die_2)
        time.sleep(1)
        print("-----------------------------------------------------")
        if player_1 %2==0:
            print("This is an even number. so +10 points")
            time.sleep(1)
            player_1=player_1+10
            time.sleep(1)
            print("score is",player_1)
            if player_1<= 0:
                print("you have lost the game")
                sys.exit()
            print("-----------------------------------------------------")

        else:
            print("This is an odd number.")
            time.sleep(2)
            player_1=player_1-5
            print("score is",player_1)
            time.sleep(3)
            print("player 1 score",player_1)
            print("-----------------------------------------------------")



        time.sleep(1)
        #player 2
        die_1 = random.randint(1,6)
        die_2 = random.randint(1,6)
        total_score_1=total_score_1+player_1
        total_score_2=total_score_2+player_2
        player_2=die_1+die_2
        print("-----------------------------------------------------")
        asdf = input("player 2 press enter to roll")

        print("player 2 is rolling")
        time.sleep(1)
        print("player 2's first roll is",die_1)
        time.sleep(1)
        asdf = input("player 2 press enter to roll again")
        time.sleep(1)
        print("player 2's second roll is",die_2)
        time.sleep(1)
        print("-----------------------------------------------------")

        if player_2 %2==0:
            print("This is an even number. so +10 points")
            time.sleep(1)
            player_2=player_2+10
            print("score is",player_2)
            time.sleep(1)
            if player_2<= 0:
                print("you have lost the game")
                sys.exit()
            print("-----------------------------------------------------")

        else:
            print("This is an odd number.")
            time.sleep(1)
            player_2=player_2-5
            print("score is",player_2)
            time.sleep(3)
            print("player 2 score",player_2)
            print("-----------------------------------------------------")

    print("the total score for player 1 is ",total_score_1)
    print("the total score for player 2 is ",total_score_2)
    if total_score_1 > total_score_2:
        print("player 1 wins")
        file = open("scores.txt2","a+")
        file.write("player 1 ")
        file.write(username1)
        file.write(" has won overall with ")
        file.write(str(total_score_1))
        file.write(" points")
        file.write("\n")

    if total_score_2 > total_score_1:
        print("player 2 wins")
        file = open("scores.txt2","a+")
        file.write("player 2 ")
        file.write(username2)
        file.write(" has won overall with ")
        file.write(str(total_score_2))
        file.write(" points")
        file.write("\n")     


if __name__ == '__main__':
    main()