"<str>x<str>x<float>-<str>:<int>x<int>₽»"
import re
...
def teststr(data: str):
floatre = r"([0-9](?:_?[0-9])*\.(?:[0-9](?:_?[0-9])*)?|\.[0-9](?:_?[0-9])*)"
intre = r"(0[xX](?:_?[0-9a-fA-F])+|0[bB](?:_?[01])+|0[oO](?:_?[0-7])+|(?:0(?:_?0)*|[1-9](?:_?[0-9])*))"
strre = r"([^'\\]*(?:\\.[^'\\]*)*'|[^\"\\]*(?:\\.[^\"\\]*)*\")"
regex = re.compile(r"[a-zA-Z]+x[a-zA-Z]+x"+floatre+r"-[a-zA-Z]+:"+intre+r"x"+intre+r"₽»")
return re.match(regex, data)
...
class Background(dict):
def __init__(self, image, x=0):
self['i'], self['x'] = image, x
pass
def draw(self, surface):
surface.blit(self['i'], (self['x'], 0))
surface.blit(self['i'], (self['x']-self['i'].get_width(), 0))
self['x'] += 1
if self['x'] >= self['i'].get_width(): x = 0
pass
pass
def flatten(array: list):
def popen(arr: list | tuple):
if not arr or not arr[0]:
return arr
while type(arr[0]) in (tuple, list):
arr = arr[0]
pass
return arr
if len(array) in (0, 1):
return popen(array)
if type(array[0]) == str:
if type(array[1]) == list:
return [array[0], *flatten(array[1:])]
pass
return array
raise RuntimeError
def detect(text):
k = 10 # koefficient
ru = 'абвгдежзиклмнопрстуфхцчщьыъэюя'
en = 'abcdefghijklmnopkrstuvwxyz'
cd = '[]{}()_=+/\\|@#$%^&*'
ru_c = 0 # c - chance
en_c = 0 # c - chance
cd_c = 0 # c - chance
max_cd_syms = 1 # syms - symbols
for s in str(text.casefold()): # str() for refuse some chance of exception
if s in ru:
ru_c += 1
continue
if s in en:
en_c += 1
cd_c += .5
continue
if s in cd:
cd_c += (max_cd_syms*len(text)//k)
continue
pass
#print(ru_c, en_c, cd_c) # debug
if ru_c > en_c and ru_c > cd_c:
return 'ru'
if en_c > ru_c and en_c > cd_c:
return 'en'
if cd_c > ru_c and cd_c > en_c:
return 'code'
return 'mixed'
#
text1 = '''Минобороны показало уничтожение высокоточным оружием артиллерийской батареи'''
text2 = '''O curse of marriage!
That we can call these delicate creatures ours,
And not their appetites! I had rather be a toad
And live upon the vapour of a dungeon
Than keep a corner in the thing I love
For others' uses.'''
text3 = '''_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'amper apos back bux colon comma comment dog dot equ expl flex float ignore int lang lblc lfig lpar minus multilinecomment name newline percent plus rang rblc rfig rpar semi sharp slash star str tildeline : preptag\n | assign\n | func\n | cyclepreptag : sharp lblc name rblc\n | sharp lblc name colon name rblc\n | sharp lblc name colon int rblcassign : name equ expr\n | name equ namefunc : name lpar args rpar\n | name lpar rparexpr : intcycle : name lpar args rpar lfig rfigargs : name\n | expr\n | name comma args\n | expr comma args'
_lr_action_items = {'sharp':([0,],[6,]),'name':([0,8,9,10,20,21,23,],[7,11,12,15,24,15,15,]),'$end':([1,2,3,4,5,12,13,14,17,19,22,29,30,31,],[0,-1,-2,-3,-4,-9,-8,-12,-11,-5,-10,-6,-7,-13,]),'lblc':([6,],[8,]),'equ':([7,],[9,]),'lpar':([7,],[10,]),'int':([9,10,20,21,23,],[14,14,25,14,14,]),'rpar':([10,14,15,16,18,26,28,],[17,-12,-14,22,-15,-16,-17,]),'rblc':([11,24,25,],[19,29,30,]),'colon':([11,],[20,]),'comma':([14,15,18,],[-12,21,23,]),'lfig':([22,],[27,]),'rfig':([27,],[31,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'line':([0,],[1,]),'preptag':([0,],[2,]),'assign':([0,],[3,]),'func':([0,],[4,]),'cycle':([0,],[5,]),'expr':([9,10,21,23,],[13,18,18,18,]),'args':([10,21,23,],[16,26,28,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> line","S'",1,None,None,None),
('line -> preptag','line',1,'p_line','lexyac.py',197),
('line -> assign','line',1,'p_line','lexyac.py',198),
('line -> func','line',1,'p_line','lexyac.py',199),
('line -> cycle','line',1,'p_line','lexyac.py',200),
('preptag -> sharp lblc name rblc','preptag',4,'p_preptag','lexyac.py',203),
('preptag -> sharp lblc name colon name rblc','preptag',6,'p_preptag','lexyac.py',204),
('preptag -> sharp lblc name colon int rblc','preptag',6,'p_preptag','lexyac.py',205),
('assign -> name equ expr','assign',3,'p_assign','lexyac.py',209),
('assign -> name equ name','assign',3,'p_assign','lexyac.py',210),
('func -> name lpar args rpar','func',4,'p_func','lexyac.py',214),
('func -> name lpar rpar','func',3,'p_func','lexyac.py',215),
('expr -> int','expr',1,'p_expr','lexyac.py',219),
('cycle -> name lpar args rpar lfig rfig','cycle',6,'p_cycle','lexyac.py',223),
('args -> name','args',1,'p_args','lexyac.py',227),
('args -> expr','args',1,'p_args','lexyac.py',228),
('args -> name comma args','args',3,'p_args','lexyac.py',229),
('args -> expr comma args','args',3,'p_args','lexyac.py',230),
]'''
#
print(detect(text1), detect(text2), detect(text3))
#
input()
groundRect.collidepoint(granadeRectPoint)
# True если перекрывается
granadeRect = granadeImage.get_rect()
groundRect.collidepoint(granadeRectPoint)
# True если перекрывается
import threading, sys
from pygame import *
font.init()
def thread(func):
def _sugar(*args) -> threading.Thread:
ret = threading.Thread(target = func, args = [*args,])
ret.start()
return ret
return _sugar
class Counter(object):
def __init__(s, w, h, bind, fg = Color(0, 255, 0), bg = Color(0, 0, 0),value=0, fnt = font.SysFont(None, 14)):
s.w,\
s.h,\
s.fg,\
s.bg,\
s.vl,\
s.fnt =\
w,h,fg,bg,value,fnt
s.bnd = bind
pass
def increase(s, step = 1):
s.vl += step
pass
def decrease(s, step = 1):
s.vl -= step
pass
def render(s):
ret = Surface((s.w, s.h), HWSURFACE|SRCALPHA)
ret.fill(s.bg)
ret.blit(transform.smoothscale(s.fnt.render(str(s.vl), 1, s.fg), ret.get_size()), (0, 0))
return ret
@thread
def bnd(s):
pass
pass
#
@thread
def bind(counter, event):
if event.type in (MOUSEBUTTONDOWN, MOUSEBUTTONUP):
counter.increase()
pass
pass
#
def main(argv):
display.init()
font.init()
sc = display.set_mode((800, 600), HWSURFACE|SRCALPHA)
counter = Counter(600, 400, bind, fnt = font.SysFont(None, 1024))
ticker = time.Clock()
target_FPS = 120
real_FPS = 0
while True:
ticker.tick(target_FPS)
real_FPS = ticker.get_fps()
for e in event.get():
if e.type == QUIT:
display.quit()
quit()
sys.exit()
pass
counter.bnd(counter, e)
pass
sc.fill((255,100,100))
sc.blit(counter.render(), (100, 100))
display.flip()
display.set_caption(f"Clicker based on counter [FPS: {int(real_FPS)}]")
pass
pass
if __name__ == '__main__':
main(sys.argv)
pass
def __init__(self, image, x, y,):
def __init__(self, _image, x, y,):
self.image = transform.scale(image.load("flopa.png"), (50, 50))
self.image = transform.scale(image.load(_image), (50, 50))
def __init__(self, image, x, y>>,<<)