# saint_patrick.py

Created by numworks

Created on March 16, 2021

2.51 KB

Pour faire fonctionner ce script sur votre calculatrice, installez la dernière mise à jour depuis votre compte NumWorks !

```from kandinsky import *
from time import *
from ion import *
from random import *
from turtle import *

#COLORS
black = (0,0,0)
ocre = (250,210,125)
green = (25,210,0)
grey = (236,235,235)
yellow = (255,180,50)
white = (246,245,245)
white2 = (255,255,255)

def draw_icon(x,image_type):
offset = 1
if x == 2:
offset = 70
if x == 3:
offset = 140
fill_rect(32+offset,41,66,78,white2)
if image_type == 1:
draw_clover(offset)
elif image_type == 2:
draw_hat(offset)
else:
draw_beer(offset)

def draw_casino():
fill_rect(32,33,208,8,yellow)
fill_rect(24,33,8,154,yellow)
fill_rect(32,179,208,8,yellow)
fill_rect(240,33,9,154,yellow)
fill_rect(98,41,6,78,yellow)
fill_rect(169,41,6,78,yellow)
fill_rect(32,119,208,6,yellow)
fill_rect(253,129,14,30,yellow)
fill_rect(269,107,9,45,yellow)
fill_rect(278,107,4,14,yellow)
fill_rect(284,76,9,45,yellow)
fill_rect(265,33,40,40,yellow)
draw_string("OK",276,45,white2,yellow)

def draw_clover(offset):
fill_rect(46+offset,64,18,12,green)
fill_rect(52+offset,58,12,6,green)
fill_rect(65+offset,58,11,6,green)
fill_rect(65+offset,64,18,12,green)
fill_rect(46+offset,77,6,12,green)
fill_rect(52+offset,83,11,10,green)
fill_rect(52+offset,77,12,6,green)
fill_rect(65+offset,77,13,6,green)
fill_rect(78+offset,77,5,11,green)
fill_rect(64+offset,84,1,13,green)
fill_rect(59+offset,97,11,4,green)
fill_rect(66+offset,83,12,10,green)

def draw_beer(offset):
#glass
fill_rect(50+offset,55,29,51,grey)
fill_rect(79+offset,60,11,4,grey)
fill_rect(86+offset,64,4,21,grey)
fill_rect(79+offset,85,11,4,grey)
#foam
fill_rect(53+offset,55,23,7,white)
#beer
fill_rect(53+offset,62,23,41,ocre)
fill_rect(56+offset,66,2,26,white)

def draw_hat(offset):
fill_rect(49+offset,55,33,39,green)
fill_rect(41+offset,101,49,4,green)
fill_rect(49+offset,94,13,7,black)
fill_rect(70+offset,94,12,7,black)
fill_rect(62+offset,94,8,7,yellow)

def gambling():
icons = 3
icon_left = randint(1,icons)
icon_middle = randint(1,icons)
icon_right = randint(1,icons)
draw_icon(1, icon_left)
draw_icon(2, icon_middle)
draw_icon(3, icon_right)

if (icon_left==icon_middle) and (icon_middle==icon_right):
return True
else:
return False

draw_casino()

while (True):
if keydown(KEY_OK):
fill_rect(32,125,208,53,white2)
result = False
for i in range(20):
result = gambling()
if result:
draw_string("You win !",90,140,black)
else:
draw_string("Try again",90,140,black)
sleep(0.01)```