Update app.py
Browse files10 unmodified lines11121314151617181920212223242526272829303132333435361 unmodified line3839404142436 unmodified lines505152535455565758596061626338 unmodified lines10210310410510610710819 unmodified lines12812913013113213313410 unmodified lines}def draw_scene(keeper_pos, ball_dir, is_goal):# Thủ môn bay ngườikeeper_move = {"trái": "translateX(-80px) rotate(-20deg)","giữa": "translateX(0px)","phải": "translateX(80px) rotate(20deg)"}# Bóng bayif is_goal:ball_path = {"trái": "translate(-120px, -180px)","giữa": "translate(0px, -200px)","phải": "translate(120px, -180px)"}else: # cản phá, bóng văng sang bên ngoàiball_path = {"trái": "translate(-180px, -50px)","giữa": "translate(0px, -50px)","phải": "translate(180px, -50px)"}# Màu áo cầu thủ theo độiif state["turn"] == "A":shirt_color = "#2196F3"pants_color = "#1565C0"1 unmodified lineshirt_color = "#e53935"pants_color = "#b71c1c"html = f"""<div style="position:relative;width:100%;height:360px;background:linear-gradient(#4CAF50,#2e7d32);border-radius:20px;overflow:hidden;"><!-- Khung thành -->6 unmodified lines<!-- Thủ môn --><div style="position:absolute;top:120px;left:50%;transform:{keeper_move[keeper_pos]};transition: all 0.4s ease;"><div style="width:18px;height:18px;background:#ffd1a4;border-radius:50%;margin:auto;"></div><div style="width:30px;height:45px;background:#2196F3;border-radius:8px;margin:auto;"></div><div style="display:flex;justify-content:space-between;"><div style="width:8px;height:25px;background:#2196F3;transform:rotate(30deg);"></div><div style="width:8px;height:25px;background:#2196F3;transform:rotate(-30deg);"></div></div><div style="display:flex;justify-content:space-between;"><div style="width:8px;height:25px;background:#1565C0;"></div><div style="width:8px;height:25px;background:#1565C0;"></div></div></div>38 unmodified linesif hit: state["score_b"] +=1msg = f"Đội {state['turn']} sút {direction}, thủ môn đoán {keeper} → "msg += "⚽ Bàn thắng!" if hit else "🧤 Cản phá!"scene = draw_scene(keeper, direction, hit)19 unmodified linesreturn 0,0,1,"A","Game mới bắt đầu! Đội A sút trước.",scenewith gr.Blocks() as demo:gr.Markdown("# ⚽ Penalty 2 Đội – 5 lượt + Bóng văng khi cản phá")score_a = gr.State(0)score_b = gr.State(0)10 unmodified lines111213141516171819202122232425262728293031323334353637381 unmodified line404142434445464748496 unmodified lines565758596061626364656667686938 unmodified lines10810911011111211311419 unmodified lines13413513613713813914010 unmodified lines}def draw_scene(keeper_pos, ball_dir, is_goal):keeper_move = {"trái": "translateX(-80px) rotate(-20deg)","giữa": "translateX(0px)","phải": "translateX(80px) rotate(20deg)"}# bóng sẽ dính vào thủ môn nếu cản pháif is_goal:ball_path = {"trái": "translate(-120px, -180px)","giữa": "translate(0px, -200px)","phải": "translate(120px, -180px)"}else:# bóng dính vào thủ môn (ở chính giữa đầu/thân thủ môn)ball_path = {"trái": "translate(0px, 0px)","giữa": "translate(0px, 0px)","phải": "translate(0px, 0px)"}# màu áo cầu thủ theo độiif state["turn"] == "A":shirt_color = "#2196F3"pants_color = "#1565C0"1 unmodified lineshirt_color = "#e53935"pants_color = "#b71c1c"# Thủ môn áo vàng cố địnhkeeper_shirt = "#FFEB3B"keeper_pants = "#FBC02D"html = f"""<div style="position:relative;width:100%;height:360px;background:linear-gradient(#4CAF50,#2e7d32);border-radius:20px;overflow:hidden;"><!-- Khung thành -->6 unmodified lines<!-- Thủ môn --><div style="position:absolute;top:120px;left:50%;transform:{keeper_move[keeper_pos]};transition: all 0.4s ease;"><div style="width:18px;height:18px;background:#ffd1a4;border-radius:50%;margin:auto;"></div><div style="width:30px;height:45px;background:{keeper_shirt};border-radius:8px;margin:auto;"></div><div style="display:flex;justify-content:space-between;"><div style="width:8px;height:25px;background:{keeper_shirt};transform:rotate(30deg);"></div><div style="width:8px;height:25px;background:{keeper_shirt};transform:rotate(-30deg);"></div></div><div style="display:flex;justify-content:space-between;"><div style="width:8px;height:25px;background:{keeper_pants};"></div><div style="width:8px;height:25px;background:{keeper_pants};"></div></div></div>38 unmodified linesif hit: state["score_b"] +=1msg = f"Đội {state['turn']} sút {direction}, thủ môn đoán {keeper} → "msg += "⚽ Bàn thắng!" if hit else "🧤 Cản phá, bóng dính thủ môn!"scene = draw_scene(keeper, direction, hit)19 unmodified linesreturn 0,0,1,"A","Game mới bắt đầu! Đội A sút trước.",scenewith gr.Blocks() as demo:gr.Markdown("# ⚽ Penalty 2 Đội – Thủ môn vàng + Bóng dính thủ môn")score_a = gr.State(0)score_b = gr.State(0)
app.py+20-14