13 Commits

Author SHA1 Message Date
20241144010013 ad3602ba8b Atualizar CatMaus/CatMaus.py 2025-02-03 20:52:20 +00:00
Kaio Henrique 1720f77f00 AutopyStartUp 2025-01-27 11:31:27 -03:00
Kaio Henrique 19a9d1fafa remove manima 2025-01-26 17:24:59 -03:00
20241144010013 8f05eb6d2c update Catmaus 2025-01-20 17:41:53 -03:00
20241144010013 c055b048df minor CatMaus update 2024-12-05 17:25:21 -03:00
Kaio Henrique 74f77706c9 cancel manima project 2024-12-01 21:16:08 -03:00
Kaio Henrique bffbecab78 merge 2024-12-01 14:47:58 -03:00
Kaio Henrique ba9aa38055 animação + Cat and Maus 2024-12-01 14:43:22 -03:00
20241144010013 1e6459eece config turnos 2024-11-28 17:07:23 -03:00
Kaio Henrique 6387992312 Test Single Player 2024-11-28 11:48:58 -03:00
20241144010013 b62d22aa4c battle 2024-11-25 17:58:34 -03:00
Kaio Henrique 93eda0f85f Naval Battle 1.1 2024-11-25 12:47:10 -03:00
20241144010013 92a6efc621 V2.0 2024-11-21 14:28:17 -03:00
9 changed files with 547 additions and 359 deletions
+207
View File
@@ -0,0 +1,207 @@
import turtle as tl
import random as rd
#setup
tl.setup(600,600,None,None)
tl.hideturtle()
tl.colormode(255)
t = tl.Turtle()
t.color("Blue")
t.goto(-100,0)
t2 = tl.Turtle()
t2.color("Red")
t2.goto(100,0)
tl.tracer(1)
cheese = tl.Turtle()
cheese.color("Yellow")
cheese.shape("square")
cheese.up()
cheese.goto(-600,600)
#CENÁRIO
#moldura
tl.tracer(0)
tl.color("black")
tl.up()
tl.goto(-300,-300)
tl.down()
tl.goto(-300,300)
tl.goto(300,300)
tl.goto(300,-300)
#queijo
possible_pos = [(200,250),(-100,-250), (250,-250),(-50,200),(100,-150),(100,0)]
#linhas
tl.bgcolor((205, 133, 63))
for _ in range(-6, 6):
tl.color((139, 69, 19))
tl.up()
tl.goto(-300, _ * 50)
tl.down()
tl.goto(300, _ * 50)
tl.up()
tl.color("light blue")
tl.goto(-300, 300)
tl.down()
tl.begin_fill()
#parede
tl.goto(-300, 250)
tl.goto(300, 250)
tl.goto(300,300)
tl.end_fill()
#casa de rato
tl.up()
tl.goto(170, 250)
tl.color("black")
tl.down()
tl.begin_fill()
tl.goto(190,250)
tl.goto(190,260)
tl.left(90)
tl.circle(10, 180)
tl.end_fill()
#FIM-CENÁRIO
tl.update()
tl.tracer(1)
#funções
global tem_queijo
tem_queijo = False
#pass
def colide():
global tem_queijo
rng = rd.randint(0,5)
chance_tocheese = rd.randint(0,100)
if t.distance(t2) < 10 and tem_queijo == False:
print("Vitoria do Gato")
tl.bye()
elif t.pos()[1] > 250 or t.pos()[1] < -300 or t.pos()[0] > 300 or t.pos()[0] <- 300:
t.goto(0,0)
elif t2.pos()[1] > 250 or t2.pos()[1] < -300 or t2.pos()[0] > 300 or t2.pos()[0] < -300:
t2.goto(0,0)
elif t.distance(t2) < 10 and tem_queijo == True:
print("Vitoria do Rato")
tl.bye()
if chance_tocheese <= 5:
tl.tracer(0)
cheese.goto(possible_pos[rng])
tl.update()
tl.tracer(1)
if t.distance(cheese) < 10:
print("queijo coletado!")
tem_queijo = True
cheese.hideturtle()
def godir():
tl.tracer(0)
t.seth(0)
t.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def goleft():
tl.tracer(0)
t.seth(180)
t.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def goup():
tl.tracer(0)
t.seth(90)
t.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def godown():
tl.tracer(0)
t.seth(270)
t.forward(50)
tl.update()
tl.tracer(1)
colide()
# pass
#segunda tartaruga
def godir2():
tl.tracer(0)
t2.seth(0)
t2.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def goleft2():
tl.tracer(0)
t2.seth(180)
t2.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def goup2():
tl.tracer(0)
t2.seth(90)
t2.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
def godown2():
tl.tracer(0)
t2.seth(270)
t2.forward(50)
tl.update()
tl.tracer(1)
colide()
#pass
#execução
tl.onkeypress(godir,"d")
tl.onkeypress(goleft,"a")
tl.onkeypress(goup,"w")
tl.onkeypress(godown, "s")
tl.onkeypress(godir2,"Right")
tl.onkeypress(goleft2,"Left")
tl.onkeypress(goup2,"Up")
tl.onkeypress(godown2, "Down")
tl.listen()
#loop
tl.mainloop()
+316
View File
@@ -0,0 +1,316 @@
#esse jogo ainda está sob teste... e não deve ser considerado completo
#setup
import turtle as tl
import random
posx = [-200, -100, 0, 100, 200]
posy = [-200, -100, 0, 100, 200]
tl.setup(650,650,None,None)
tl.title("Naval Battle 1943 Loading...")
tl.speed(0)
#posições possiveis
tiro_pos = {
"A1": (200,200),
"A2": (200,100),
"A3": (200,0),
"A4": (200,-100),
"A5": (200,-200),
"B1": (100,200),
"B2": (100,100),
"B3": (100,0),
"B4": (100,-100),
"B5": (100,-200),
"C1": (0,200),
"C2": (0,100),
"C3": (0,0),
"C4": (0,-100),
"C5": (0,-200),
"D1": (-100,200),
"D2": (-100,100),
"D3": (-100,0),
"D4": (-100,-100),
"D5": (-100,-200),
"E1": (-200,200),
"E2": (-200,100),
"E3": (-200,0),
"E4": (-200,-100),
"E5": (-200,-200),
"QUIT": (1000, 1000),
}
#funções
def linhax(x,y):
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x+600,y)
#pass
def linhay(x,y):
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x,y+600)
#pass
#radar screen
tl.bgcolor("lime green")
#moldura
tl.tracer(0)
linhax(-300,-300)
linhay(-300,-300)
linhay(300,-300)
linhax(-300,300)
#linhas X
linhax(-300,-200); tl.write("5",False,align="right")
linhax(-300,-100); tl.write("4",False,align="right")
linhax(-300,0); tl.write("3",False,align="right")
linhax(-300,100); tl.write("2",False,align="right")
linhax(-300,200); tl.write("1",False,align="right")
#linhas Y
linhay(-200,-300); tl.write("E",False,align="right")
linhay(-100,-300); tl.write("D",False,align="right")
linhay(0,-300); tl.write("C",False,align="right")
linhay(100,-300); tl.write("B",False,align="right")
linhay(200,-300); tl.write("A",False,align="right")
#Tabuleiro pronto
tl.update()
tl.tracer(1)
tl.title("Naval Battle 1943")
tl.hideturtle()
bullet = tl.Turtle()
bullet.color("Yellow")
bullet.hideturtle()
bullet.up()
#gamemode SinglePlayer
gmode = tl.textinput("Modo de Jogo","Qual Modo Deseja jogar?\ndigite multi para jogar com um amigo do lado\ne single para jogar sozinho")
if gmode == "single":
win = False
print("Modo Solitario Selecionado! escolha onde ficaram seus navios")
#Player 1
p1 = tl.Turtle()
p1.up()
spawnp1 = "A1" #str(input("Senhor, Onde Nosso Submarino Deve Ficar? "))
p1.goto(tiro_pos[spawnp1])
p2 = tl.Turtle()
p2.up()
spawnp2 = "A2" #str(input("Senhor, Onde Nosso Crusador Deve Ficar? "))
p2.goto(tiro_pos[spawnp2])
p3 = tl.Turtle()
p3.up()
spawnp3 = "A3" #str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
p3.goto(tiro_pos[spawnp3])
#pass
#inimigos
e1 = tl.Turtle()
e1.up()
e1.color("red")
e1.goto(random.choice(posx), random.choice(posy))
e2 = tl.Turtle()
e2.up()
e2.color("red")
e2.goto(random.choice(posx), random.choice(posy))
if e1.pos() == e2.pos():
e2.goto(random.choice(posx), random.choice(posy))
e3 = tl.Turtle()
e3.up()
e3.color("red")
e3.goto(random.choice(posx), random.choice(posy))
if e1.pos() == e3.pos():
e3.goto(random.choice(posx), random.choice(posy))
if e2.pos() == e3.pos():
e3.goto(random.choice(posx), random.choice(posy))
#pass
while win == False:
tiro = tl.textinput("Onde Devemos Disparar?","Em Qual Intersecão Devemos Disparar?\nDigite (quit) Para Sair").upper()
while tiro not in tiro_pos:
tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
#acerto Submarino
if (tiro_pos[tiro]) == e1.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("U-boat Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e1.goto(-1000,-1000)
#acerto Crusador
elif (tiro_pos[tiro]) == e2.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("Crusador Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e2.goto(-1000,-1000)
#acerto Destroyer
elif(tiro_pos[tiro]) == e3.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("Destroyer Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e3.goto(-1000,-1000)
#erro
elif (tiro_pos[tiro]) != e1.pos() and (tiro_pos[tiro]) != e2.pos() and (tiro_pos[tiro]) != e3.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("errou!")
bullet.write("Erramos o alvo\n Capitão!",False,align="center")
bullet.hideturtle()
#vencer
if (e1.pos() == (-1000, -1000)) and (e2.pos() == (-1000, -1000)) and (e3.pos() == (-1000, -1000)):
print("voçe ganhou")
break
#sair
if bullet.pos() == (1000, 1000):
break
#tiro inimigo
tiro_e = tl.Turtle()
tiro_e.hideturtle()
#acerto Submarino
if (tiro_pos[tiro_e]) == p1.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro_e])
print("Acerto!")
bullet.write("U-boat Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e1.goto(-1000,-1000)
#acerto Crusador
elif (tiro_pos[tiro]) == p2.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("Crusador Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e2.goto(-1000,-1000)
#acerto Destroyer
elif(tiro_pos[tiro_e]) == p3.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro_e])
print("Acerto!")
bullet.write("Destroyer Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
e3.goto(-1000,-1000)
#erro
elif (tiro_pos[tiro_e]) != p1.pos() and (tiro_pos[tiro_e]) != p2.pos() and (tiro_pos[tiro_e]) != p3.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro_e])
print("errou!")
bullet.write("Erramos o alvo\n Capitão!",False,align="center")
bullet.hideturtle()
#vencer
if (p1.pos() == (-1000, -1000)) and (p2.pos() == (-1000, -1000)) and (p3.pos() == (-1000, -1000)):
print("voçe ganhou")
break
#sair
if tiro_e.pos() == (1000, 1000):
break
#Multiplayer
elif gmode == "multi":
win = False
print("Modo Multiplayer Selecionado! Fique ao lado de seu amigo\nnão olhe os navios dele e vice-versa")
#Player 1
p1 = tl.Turtle()
p1.up()
spawnp1 = str(input("Senhor, Onde Nosso Submarino Deve Ficar? "))
p1.goto(tiro_pos[spawnp1])
p2 = tl.Turtle()
p2.up()
spawnp2 = str(input("Senhor, Onde Nosso Crusador Deve Ficar? "))
p2.goto(tiro_pos[spawnp2])
p3 = tl.Turtle()
p3.up()
spawnp3 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
p3.goto(tiro_pos[spawnp3])
#pass
#player 2
p1_2 = tl.Turtle()
p1_2.up()
spawnp1_2 = str(input("Senhor, Onde Nosso Submarino Deve Ficar? "))
p1_2.goto(tiro_pos[spawnp1_2])
p2_2 = tl.Turtle()
p2_2.up()
spawnp2_2 = str(input("Senhor, Onde Nosso Crusador Deve Ficar? "))
p2_2.goto(tiro_pos[spawnp2_2])
p3_2 = tl.Turtle()
p3_2.up()
spawnp3_2 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
p3_2.goto(tiro_pos[spawnp3_2])
#pass
while win == False:
tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
if (tiro_pos[tiro]) == p1.pos() or (tiro_pos[tiro]) == p1_2.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("U-boat Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
break
elif (tiro_pos[tiro]) == p2.pos() or (tiro_pos[tiro]) == p2_2.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("Crusador Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
break
elif(tiro_pos[tiro]) == p3.pos() or (tiro_pos[tiro]) == p3_2.pos():
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("Acerto!")
bullet.write("Destroyer Afundado\n Capitão!",False,align="center")
bullet.hideturtle()
break
else:
bullet.showturtle()
bullet.goto(tiro_pos[tiro])
print("errou!")
bullet.write("Erramos o alvo\n Capitão!",False,align="center")
bullet.hideturtle()
continue
#partidas
#TELA DE VITORIA
#Execução
tl.mainloop()
tl.exitonclick()
+3 -3
View File
@@ -1,4 +1,4 @@
# Sobre
Repositorio que contem uma versão **MELHORADA** de batalha naval.
# 20241144010013
# Repository for random Projects that run through my mind
Fork do [repositório de Kaio Henrique](https://gitea.mange.ifrn.edu.br/20241144010013/20241144010013)
+21
View File
@@ -0,0 +1,21 @@
import pyautogui as auto
confirma = auto.confirm("Startar o programa", "Start-up", buttons=["Sim", "Não"])
if confirma == "Sim":
senha = auto.password(text='Qual sua Senha do SUAP', title='Senha', default='', mask='*')
auto.PAUSE = 1.5
auto.press("win")
auto.write("chrome")
auto.press("enter")
auto.write("https://suap.ifrn.edu.br/accounts/login/")
auto.press("enter")
auto.write("20241144010013")
auto.press("tab")
auto.write(senha)
auto.press("enter")
auto.hotkey("ctrl","t")
auto.press("win")
auto.write("code")
auto.press("enter")
-79
View File
@@ -1,79 +0,0 @@
def make_board(size: int, filler = 0) -> list:
return [[filler for _ in range(size)] for _ in range(size)]
class DrawerHelper:
@staticmethod
def draw_columnsnrows(board) -> None:
max_num_len = len(str(len(board) - 1))
# Currently inserts the columns and rows into the board
for i in range(len(board)):
for j in range(len(board[i])):
if i == 0 and j == 0:
board[i][j] = " " * max_num_len
elif i == 0:
board[i][j] = chr(j + 64)
elif j == 0:
board[i][j] = str(i).rjust(max_num_len)
else:
board[i][j] = " "
def draw_ships(board, ships) -> None:
for i in range(len(ships)):
for j in range(len(ships[i])):
if ships[i][j] == 1:
board[i + 1][j + 1] = "B"
def draw_shots(board, hit_ships) -> None:
for i in range(len(hit_ships)):
for j in range(len(hit_ships[i])):
if hit_ships[i][j] == 1:
board[i + 1][j + 1] = "X"
if hit_ships[i][j] == -1:
board[i + 1][j + 1] = "O"
def draw_board(board) -> None:
for i in range(len(board)):
for j in range(len(board[i])):
print(board[i][j], end=" ")
print()
class Game:
def __init__(self, board_size: int, enemy_amount: int = 5) -> None:
self.my_ships = make_board(board_size)
# Two different boards, one to show your ships and one to show the places you have shot
self.hit_ships = make_board(board_size) # -1 = shot but not hit, 0 = not hit, 1 = hit
self.total_enemy_amount = enemy_amount
self.my_drawn_board = make_board(board_size + 1, " ")
self.enemy_drawn_board = make_board(board_size + 1, " ")
@property
def enemy_amount(self) -> int:
# Get the enemy amount based on the amount of ships that are not hit in the hit ships var
return self.total_enemy_amount - sum([row.count(1) for row in self.hit_ships])
def draw(self) -> None:
DrawerHelper.draw_ships(self.my_drawn_board, self.my_ships)
DrawerHelper.draw_shots(self.my_drawn_board, self.hit_ships)
DrawerHelper.draw_board(self.my_drawn_board)
def hit(self, x: int, y: int, state: int) -> None:
self.hit_ships[x][y] = state
def shoot(self, x: int, y: int) -> int:
"""Shot at own board and return hit or not hit"""
if self.my_ships[x][y] == 1:
return 1
return -1
na = Game(5)
DrawerHelper.draw_columnsnrows(na.my_drawn_board)
na.my_ships[2][2] = 1
na.hit(1, 2, na.shoot(1, 2))
na.draw()
-130
View File
@@ -1,130 +0,0 @@
#setup
import turtle as tl
import random, sys
args = sys.argv
# name, -arguments
def has_argument(args: list[str], arg: str) -> bool:
if len(args) > 1:
if args[1].startswith("-"):
for chr in args[1]:
if chr == arg:
return True
return False
def num2char(num: int) -> chr:
return chr(num + 65)
def char2num(char: str) -> int:
return ord(char) - 65
posx = [0, 1, 2, 3, 4]
posy = [0, 1, 2, 3, 4]
postiro = []
for i in range(len(posx)):
for j in range(len(posy)):
postiro.append(f"{i-2} {j-2}")
tl.setup(650,650,None,None)
tl.title("Naval Battle 1943 Loading...")
tl.speed(0)
#funções
def linhax(x: int, y: int) -> None:
tl.up()
tl.goto(x,y)
tl.down()
tl.goto(x+600,y)
def linhay(x: int, y: int) -> None:
tl.up()
tl.goto(x,y)
tl.down()
tl.goto(x,y+600)
#radar screen
tl.bgcolor("lime green")
#moldura
linhax(-300,-300)
linhay(-300,-300)
linhay(300,-300)
linhax(-300,300)
#linhas X
for i in range(5):
linhax(-300, (i-2)*100)
tl.write(num2char(i), False, align="right")
#linhas Y
for i in range(5):
linhay((i-2)*100, -300)
tl.write(str(i), False, align="right")
#Tabuleiro pronto
tl.title("Naval Battle 1943")
tl.hideturtle()
boat = tl.Turtle()
boat.shapesize(3, 3)
boat.up()
boat.goto(0,0)
boat.left(90)
#Enemies
AMOUNT_OF_ENEMIES = 3
enemies = []
for i in range(AMOUNT_OF_ENEMIES):
enemy = tl.Turtle()
enemy.color("red")
enemy.up()
if not has_argument(args, "D"):
enemy.hideturtle()
else:
enemy.shapesize(3, 3)
pos = [random.choice(posy), random.choice(posy)]
enemy.goto((pos[0] - 2) * 100, (pos[1] - 2) * 100)
enemies.append([enemy, pos])
#partidas
win = False
while win == False:
tirox = tl.numinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
tiroy = tl.textinput("linha Y do disparo","Em qual quadrante Y devemos disparar a artilharia")
tiroy = char2num(tiroy.upper())
if tirox == None or tiroy == None:
tl.exitonclick()
boat.goto((tirox - 2) * 100, (tiroy - 2) * 100)
acerto = False
for enemy in enemies:
if [tirox,tiroy] == enemy[1]:
hit_enemy: list[tl.Turtle, list[int, int]] = enemy
acerto = True
break
if acerto:
print("Acerto!")
boat.write("U-boat Afundado\n Capitão!",False,align="center")
hit_enemy[0].hideturtle()
enemies.remove(hit_enemy)
else:
print("errou!")
boat.write("Erramos o alvo\n Capitão!",False,align="center")
acerto = False
if len(enemies) <= 0: # tamanho negativo???
win = True
print("Você ganhou!!")
tl.exitonclick()
View File
-123
View File
@@ -1,123 +0,0 @@
import socket, threading
class Networking:
"""
A class that contains common networking functions for both server and client.
"""
@staticmethod
def recv_any_size(sock):
"""
Receives data from the socket without knowing the size of the data.
The sender must send the size of the data before sending the data.
"""
data_size = sock.recv(1024).decode()
sock.send("OK".encode())
data = sock.recv(int(data_size)).decode()
return data
@staticmethod
def send_any_size(sock, data):
"""
Sends data to the socket without knowing the size of the data.
Sends the size of the data before sending the data.
"""
data_len = str(len(bytes(data, "utf-8"))).encode()
sock.send(data_len)
response = sock.recv(1024).decode()
sock.send(data.encode())
class Server:
"""
A basic server class that can be inherited to create a custom server.
Contains some basic networking functions.
"""
def __init__(self, host = "127.0.0.1", port = 8080):
"""
Hosts a basic server on the specified host and port
"""
self.host = host
self.port = port
self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server.bind((self.host, self.port))
def start(self, max_connections = 5):
"""
Starts the server and listens for *max_connections* connections, defaulted to 5
"""
self.server.listen(max_connections)
while True:
client, addr = self.server.accept()
print(f"Connection from {addr}")
# Start a new thread for the client
threading.Thread(target=self.handle_client, args=(client,)).start()
def handle_client(self, client):
"""
Checks if the client sent "exit" and closes the connection if it did, else send the data back.
Overwrite with your own implementation.
"""
while True:
data = self.recv(client)
if data == "exit":
break
self.send(client, data)
pass
def send(self, client, data):
"""
Sends data to the client
"""
Networking.send_any_size(client, data)
def recv(self, client):
"""
Receives data from the client
"""
return Networking.recv_any_size(client)
def stop(self):
"""
Stops the server
"""
self.server.close()
class Client:
"""
A basic client class that can be inherited to create a custom client.
Contains some basic networking functions.
"""
def __init__(self, host = "127.0.0.1", port = 8080):
"""
Connects to a server on the specified host and port
"""
self.host = host
self.port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
def send(self, data):
"""
Sends data to the server
"""
Networking.send_any_size(self.sock, data)
def recv(self):
"""
Receives data from the server
"""
return Networking.recv_any_size(self.sock)
def close(self):
"""
Closes the connection
"""
Networking.send_any_size(self.sock, "exit")
self.sock.close()
-24
View File
@@ -1,24 +0,0 @@
from networking import net_module
import socket, threading
class Test_server(net_module.Server):
def handle_client(self, client: socket.socket):
print(self.recv(client))
self.send(client, "Hello World")
print(self.recv(client))
client.close()
class Test_client(net_module.Client):
def main(self):
self.send("Hello World")
print(self.recv())
self.close()
server = Test_server()
threading.Thread(target=server.start, args=(1,)).start()
client = Test_client()
client.main()