исправленные import-ы
This commit is contained in:
1 parent
5fb51e51dc
commit
ac1a49e6d1
8 files changed
+6
-164
No files matched your search
Generated
-3
@@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
Generated
+1
-1
@@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.13 (PyCharmMiscProject)" />
|
<option name="sdkName" value="Python 3.13 (PyCharmMiscProject)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13 (PyCharmMiscProject)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (python)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/python.iml" filepath="$PROJECT_DIR$/.idea/python.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
+4
-2
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
<orderEntry type="jdk" jdkName="Python 3.13 (PyCharmMiscProject)" jdkType="Python SDK" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.10 (python)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
Generated
-2
@@ -1,8 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/python" vcs="Git" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
import telebot
|
|
||||||
import random
|
|
||||||
from telebot impo
|
|
||||||
|
|
||||||
token = "8379986047:AAGr74CT6Y2a8moIWL4Outspent1CajoledF9ec"
|
|
||||||
bot = telebot.TeleBot(token)
|
|
||||||
|
|
||||||
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
|
||||||
button1 = types.KeyboardButton("Камень")
|
|
||||||
button2 = types.KeyboardButton("Ножницы")
|
|
||||||
button3 = types.KeyboardButton("Бумага")
|
|
||||||
keyboard.add(button1, button2, button3)
|
|
||||||
|
|
||||||
userLink = {}
|
|
||||||
wins = {}
|
|
||||||
looses = {}
|
|
||||||
draws = {}
|
|
||||||
dif = {}
|
|
||||||
|
|
||||||
Rock = {}
|
|
||||||
Paper = {}
|
|
||||||
Scissors = {}
|
|
||||||
|
|
||||||
def addUserIfNotExist(message):
|
|
||||||
uid = message.chat.id
|
|
||||||
if uid not in userLink: userLink[uid] = 0 #персональный счётчик
|
|
||||||
if uid not in wins: wins[uid] = 0
|
|
||||||
if uid not in looses: looses[uid] = 0
|
|
||||||
if uid not in draws: draws[uid] = 0
|
|
||||||
if uid not in Rock: Rock[uid] = 0
|
|
||||||
if uid not in Paper: Paper[uid] = 0
|
|
||||||
if uid not in Scissors: Scissors[uid] = 0
|
|
||||||
return userLink.get(uid)
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['start'])
|
|
||||||
def start(message):
|
|
||||||
addUserIfNotExist(message)
|
|
||||||
bot.send_message(message.chat.id, 'Привет! Выбери уровень:\n/easy\n/normal\n/hard\n/mega_hard', reply_markup=keyboard)
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['easy', 'normal', 'hard', 'mega_hard'])
|
|
||||||
def difficulty(message):
|
|
||||||
addUserIfNotExist(message)
|
|
||||||
if message.text == "/easy": userLink[message.chat.id] = 1
|
|
||||||
elif message.text == "/normal": userLink[message.chat.id] = 2
|
|
||||||
elif message.text == "/hard": userLink[message.chat.id] = 3
|
|
||||||
elif message.text == "/mega_hard": userLink[message.chat.id] = 4
|
|
||||||
bot.send_message(message.chat.id, f"Уровень {message.text} выбран")
|
|
||||||
|
|
||||||
@bot.message_handler(func=lambda message: True)
|
|
||||||
def main_game(message):
|
|
||||||
level = addUserIfNotExist(message)
|
|
||||||
u_move = message.text.lower()
|
|
||||||
uid = message.chat.id
|
|
||||||
|
|
||||||
if u_move not in ["камень", "ножницы", "бумага"]:
|
|
||||||
bot.send_message(uid, "Используй кнопки!")
|
|
||||||
return
|
|
||||||
|
|
||||||
if u_move == "камень": Rock[uid] += 1
|
|
||||||
elif u_move == "ножницы": Scissors[uid] += 1
|
|
||||||
elif u_move == "бумага": Paper[uid] += 1
|
|
||||||
|
|
||||||
if level == 1:
|
|
||||||
botans = "Ножницы" if u_move == "камень" else "Камень" if u_move == "бумага" else "Бумага"
|
|
||||||
elif level == 3:
|
|
||||||
botans = "Бумага" if u_move == "камень" else "Камень" if u_move == "ножницы" else "Ножницы"
|
|
||||||
elif level == 4:
|
|
||||||
stats = {"камень": Rock[uid], "ножницы": Scissors[uid], "бумага": Paper[uid]}
|
|
||||||
fav = max(stats, key=stats.get)
|
|
||||||
if fav == "камень": botans = "Бумага"
|
|
||||||
elif fav == "ножницы": botans = "Камень"
|
|
||||||
else: botans = "Ножницы"
|
|
||||||
else:
|
|
||||||
botans = random.choice(["Камень", "Ножницы", "Бумага"])
|
|
||||||
|
|
||||||
bot_move_low = botans.lower()
|
|
||||||
if bot_move_low == u_move:
|
|
||||||
bot.send_message(uid, "Мой ход: {botans}\nНичья!", reply_markup=keyboard)
|
|
||||||
draws[uid] += 1
|
|
||||||
elif (u_move == "камень" and bot_move_low == "ножницы") or \
|
|
||||||
(u_move == "ножницы" and bot_move_low == "бумага") or \
|
|
||||||
(u_move == "бумага" and bot_move_low == "камень"):
|
|
||||||
bot.send_message(uid, f"Мой ход: {botans}\nПобеда!", reply_markup=keyboard)
|
|
||||||
wins[uid] += 1
|
|
||||||
else:
|
|
||||||
bot.send_message(uid, f"Мой ход: {botans}\nПроиграл!", reply_markup=keyboard)
|
|
||||||
looses[uid] += 1
|
|
||||||
|
|
||||||
bot.infinity_polling()
|
|
||||||
|
|
||||||
# 1. if uid not in Rock/Paper/Scissors: создают персональный счетчик для каждого игрока, чтобы бот не путал статистику разных людей.
|
|
||||||
#2. Rock[uid] += 1 (и аналоги): при каждом ходе пользователя бот «запоминает», какую кнопку вы нажали, прибавляя единицу к соответствующему счетчику.
|
|
||||||
#3. stats = {"камень": Rock[uid]...}: перед своим ходом бот «смотрит» в вашу историю и собирает все ваши нажатия в одну таблицу.
|
|
||||||
#4. max(stats, key=stats.get): бот вычисляет, какой ход в этой таблице встречается чаще всего.
|
|
||||||
# 5. if fav == "камень": botans = "Бумага": бот делает ход, который побеждает ваш самый популярный вариант.
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import telebot
|
|
||||||
import random
|
|
||||||
|
|
||||||
token = "8379986047:AAGr74CT6Y2a8moIWL4Otsntu1CjozdF9ec"
|
|
||||||
|
|
||||||
bot = telebot.TeleBot(token)
|
|
||||||
wins = {}
|
|
||||||
loose = {}
|
|
||||||
draw = {}
|
|
||||||
dif = {}
|
|
||||||
|
|
||||||
def addUserIfNotExist(message):
|
|
||||||
if not wins[message.from_user.id]:
|
|
||||||
wins[message.from_user.id] = 0
|
|
||||||
if not loose[message.from_user.id]:
|
|
||||||
loose[message.from_user.id] = 0
|
|
||||||
if not draw[message.from_user.id]:
|
|
||||||
draw[message.from_user.id] = 0
|
|
||||||
if not dif[message.from_user.id]:
|
|
||||||
dif[message.from_user.id] = 0
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['start'])
|
|
||||||
def start(message):
|
|
||||||
bot.send_message(message.chat.id, 'Привет, это игра "Камень, ножницы, бумага"')
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['rules'])
|
|
||||||
def rules(message):
|
|
||||||
bot.send_message(message.chat.id, 'Правила: выбираешь "Камень", "Ножницы" или "Бумага", если ты выиграл я напишу, а если нет, то ладно')
|
|
||||||
|
|
||||||
@bot.message_handler(func=lambda message:True)
|
|
||||||
def main_game(message):
|
|
||||||
ans = random.randint(1,3) #1 - камень, 2 - бумага, 3 - ножницы
|
|
||||||
if message.text == "Камень" and ans == 1:
|
|
||||||
bot.send_message(message.chat.id, "Ничья")
|
|
||||||
elif message.text == "Камень" and ans == 2:
|
|
||||||
bot.send_message(message.chat.id, "ХАХАХАХ!!! ТЫ ПРОИГРАЛ!")
|
|
||||||
elif message.text == "Камень" and ans == 3:
|
|
||||||
bot.send_message(message.chat.id, "НУУ БЛИИИН!!! ТЫ ВЫИГРАЛ!")
|
|
||||||
elif message.text == "Бумага" and ans == 2:
|
|
||||||
bot.send_message(message.chat.id, "Ничья")
|
|
||||||
elif message.text == "Бумага" and ans == 3:
|
|
||||||
bot.send_message(message.chat.id, "ХАХАХАХ!!! ТЫ ПРОИГРАЛ!")
|
|
||||||
elif message.text == "Бумага" and ans == 1:
|
|
||||||
bot.send_message(message.chat.id, "НУУ БЛИИИН!!! ТЫ ВЫИГРАЛ!")
|
|
||||||
elif message.text == "Ножницы" and ans == 1:
|
|
||||||
bot.send_message(message.chat.id, "ХАХАХАХ!!! ТЫ ПРОИГРАЛ!")
|
|
||||||
elif message.text == "Ножницы" and ans == 2:
|
|
||||||
bot.send_message(message.chat.id, "НУУ БЛИИИН!!! ТЫ ВЫИГРАЛ!")
|
|
||||||
elif message.text == "Ножницы" and ans == 3:
|
|
||||||
bot.send_message(message.chat.id, "Ничья")
|
|
||||||
|
|
||||||
bot.infinity_polling()
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import telebot
|
import telebot
|
||||||
import
|
import random
|
||||||
|
|
||||||
token = "8379986047:AAGr74CT6Y2a8moIWL4Otsntu1CjozdF9ec"
|
token = "8379986047:AAGr74CT6Y2a8moIWL4Otsntu1CjozdF9ec"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user