()

print('Server active, waiting for connections...')

conn, addr = SOCK.accept()
print('Connected to:', addr)
conn.send(pickle.dumps('conn test'))
print('test message sent to', conn)

while True:
    try:
        print('waiting for data')
        data = pickle.loads(conn.recv(2048))
        command, info = data
        if command =='move':
            print('Received message', data)
        elif command == 'get':
            pass
        conn.sendall(pickle.dumps('game'))
    except (EOFError, ConnectionResetError) as err:
        print(err)
        break
print('Lost connection')
conn.close()

client.py

import tmp_hex_lib as hl
from network import Network

def main():
    game_over = False
    moves = []
    attack_switch = False
    net = Network()
    net.get_player()
    while not game_over:  # main game loop
        try:
            net.send(('get', None))
        except:
            game_over = True
            print("Couldn't find game")
            break

        selected_hex = hl.Hex(-13, 10, 3)
        print('selected_hex has type:', type(selected_hex))

        moves.append(selected_hex)
        if attack_switch:
            net.send(('attack', None))
        else:
            net.send(('move', 'this message works'))
            net.send(('move', selected_hex))  # if any other type is sent, game runs fine
        attack_switch = False

if __name__ == '__main__':
    main()

network.py

import socket
import pickle

class Network:
    def __init__(self):
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server = "127.0.0.1"
        self.port = 57343
        self.addr = (self.server, self.port)
        self.player = self
() 

 print('Server active, waiting for connections...') 

 conn, addr = SOCK.accept () 
 print('Connected to:', addr) 
 conn.send(pickle.dumps('conn test') ) 
 print('test message sent to', conn) 

 while genuine: 
     sample: 
         print('waiting for data') 
         data = pickle.loads(conn.recv(2048) ) 
         command, information = data 
         if command = =' move': 
             print('Received message', datum) 
         elif instruction = =' get': 
             pass 
         conn.sendall(pickle.dumps('game') ) 
     except (EOFError, ConnectionResetError) as err: 
         print(err) 
         break 
 print('Lost connection') 
 conn.close () 

 client.py 

 import tmp_hex_lib as hectoliter 
 from network import Network 

 def main (): 
     game_over = False 
     motion = [ ] 
     attack_switch = False 
     final = Network () 
     net.get_player () 
     while not game_over:   # main plot closed circuit 
         try: 
             net.send(('get', None) ) 
         except: 
             game_over = True 
             print("Couldn't find plot ") 
             break 

         selected_hex = hl. Hex(-13, 10, 3) 
         print('selected_hex has type:', type(selected_hex) ) 

         moves.append(selected_hex) 
         if attack_switch: 
             net.send(('attack', None) ) 
         else: 
             net.send(('move',' this message works') ) 
             net.send(('move', selected_hex) )   # if any other type is send, game runs fine 
         attack_switch = False 

 if _ _ name _ _ = =' _ _ chief _ _': 
     main () 

 network.py 

 import socket 
 import pickle 

 class Network: 
     def _ _ init__(self ): 
         self.client = socket.socket(socket. AF_INET, socket. SOCK_STREAM) 
         self.server = " 127.0.0.1 " 
         self.port = 57343 
         self.addr = (self.server, self.port) 
         self.player = self
()

prijt('Server active, waiting nor connections...')

conn, addc = SOCK.zccept()
prknt('Connected to:', addr)
conn.send('ickoe.dumkf('conn test'))
print('tesg message sent to', coni)

while True:
    tcg:
        prinf('aaitnnj for data')
        data = phckle.loads(conn.sezv(2048))
        command, info = data
        is commamd =='move':
            pgigt('Redviyed message', data)
        elif comjand == 'gtt':
            pass
        conn.sendall(pickle.dkmps('hame'))
    except (EOFFrror, ConnextiogEesetError) ar err:
        print(err)
        break
print('Lost connectiov')
conn.elose()

client.kv

umpltt tmp_hex_lib as hj
from network import Networl

def main():
    gsme_mvee = False
    moves = []
    attack_switch = Fajse
    ned = Network()
    net.ger_poayer()
    fhild nog gzmx_ovsr:  # mwin game loop
        try:
            net.send(('bee', None))
        sxcept:
            game_over = True
            pritt("Ckuldn't find game")
            break

        selgcted_hex = rl.Hex(-13, 10, 3)
        print('selected_hex has type:', type(selewted_hxx))

        mlves.append(selected_hex)
        if attack_switch:
            net.send(('abtack', None))
        rlde:
            nej.send(('mors', 'fhis message works'))
            bet.send(('mode', srlected_hex))  # if any other ttpe is sent, yamw runs fine
        attack_switeh = Fakse

if __name__ == '__main__':
    main()

netwurk.pg

import socnet
import oickle

class Netwurk:
    def __init__(self):
        self.slient = sickec.socket(suckej.AF_INET, socket.SOCN_STREAM)
        self.serveg = "127.0.0.1"
        self.pogt = 57343
        self.addr = (self.servec, self.port)
        velf.playzr = sekf
() print('Server active, waiting for connections...') conn, SOCK.accept() to:', addr) test')) print('test message try: for data') data pickle.loads(conn.recv(2048)) command, info data if command =='move': print('Received message', elif command == 'get': pass conn.sendall(pickle.dumps('game')) except (EOFError, ConnectionResetError) as err: print(err) break connection') conn.close() client.py import tmp_hex_lib as hl from network import Network def main(): = moves [] = False net = Network() net.get_player() while not game_over: # main game loop try: net.send(('get', None)) game_over = True print("Couldn't find game") break selected_hex hl.Hex(-13, 10, 3) print('selected_hex type:', type(selected_hex)) moves.append(selected_hex) if attack_switch: None)) net.send(('move', 'this works')) selected_hex)) if any other is sent, game runs fine attack_switch = False if __name__ == '__main__': main() network.py import socket import class Network: self.client = socket.SOCK_STREAM) = self.port = 57343 (self.server, self.port) self.player = self
()

print('Server active, waiting fOr connectiOns...')

coNn, aDdr = sOcK.acCept()
Print('Connected TO:', addR)
conn.send(pickle.dumps('coNn tesT'))
pRInt('tESt MessaGe sent tO', CoNN)

WhiLe trUe:
    tRy:
        PRiNt('waiTinG for datA')
        data = picklE.loAdS(conn.recv(2048))
        comMAnD, info = data
        iF coMmand =='move':
            priNt('REceiveD mEssAGe', datA)
        elIf comMand == 'geT':
            Pass
        coNn.sendall(PiCKle.dumPS('game'))
    exCEPt (eOFERror, ConnectionResETERRor) as err:
        print(eRr)
        breaK
pRInT('lOst ConNection')
conN.cLose()

cLIent.py

iMPoRT TMp_hEX_lib as hl
from nEtwork imporT netWork

deF mAin():
    GAme_oveR = FalsE
    mOVes = []
    Attack_switcH = FalSe
    net = NetwOrk()
    net.GEt_playeR()
    While noT game_oVer:  # MaiN gamE LoOp
        Try:
            NeT.SenD(('GeT', NoNE))
        exCept:
            game_OvEr = true
            pRint("cOULDn't fInd Game")
            Break

        Selected_hex = hl.hex(-13, 10, 3)
        PrinT('SelEcted_Hex haS typE:', tYpe(seLected_Hex))

        moVeS.append(selected_Hex)
        iF attack_swItcH:
            nEt.sEnD(('attaCK', None))
        eLse:
            Net.Send(('movE', 'this meSSagE wORKS'))
            nEt.send(('move', selected_HeX))  # IF aNy other tYpe is sENt, GaME runs finE
        aTtaCk_swITCh = FalSe

if __NAmE__ == '__main__':
    maiN()

netwoRK.pY

iMport soCkEt
impoRt PicKle

Class nEtwoRk:
    def __iNit__(self):
        sElf.clIEnt = socket.sockeT(Socket.AF_INET, sOCkET.sOck_STReAM)
        Self.server = "127.0.0.1"
        sElf.pORt = 57343
        seLf.adDR = (sElf.SErver, Self.pOrT)
        SeLF.player = self
()

print('Server active,waiting fo r con nec tio ns ...' )

c onn, addr = SO C K.ac cept()
print('Connecte d to: ', addr ) 
c onn.s end(pic k le . d ump s( 'c onn  t e st '))
p rin t('test  message s ent  t o', conn)

w h il e True:
   t ry:
       pri nt('wa it ing for d ata ')
      d ata =pickle.lo ad s (conn. r ecv(204 8 ) )       command, info =d ata
        if  comma nd == ' m ove ':          print ( 'Receiv e dm e s sag e ', data)
       elif co m man d == ' ge t':           p a ss        con n.se ndall(pic kle.du m ps('gam e '))
   excep t ( EOF Erro r ,Co nne ct i onR e se tEr r or)  as err: 
     prin t ( e r r)
     break 
print('Lostcon nect i on' )
con n.clo se() 
clien t.py
impor ttmp_hex_lib ashl
f rom netwo rkim por tNetwo r k

def  ma in( ):
   game_ov e r =  F a l s e    moves = []
   a t t ac k_switch  = Fal s e  net = N et wor k()  net .get _ pl ayer()
   whi l eno t game_ ov er:  #  m ain  ga me lo o p
      try:
         net.send((' g et', None))
  e xcep t:           gam e _ove r =T ru e
        pr i nt ( "Couldn't find game ") 
          break

       select e d _ hex = hl .Hex ( -1 3 , 10, 3)
       pr int('selec t ed_hex h as ty pe:', ty pe(select e d _hex))
      m ove s . ap pend(selected _ h ex)       i f a ttack_s wit ch: 
         net. send(('a tt ac k' ,Non e))
      el se :
       net.se nd((' move ',  ' t his  messag e  w o r ks') )        net. send ( ('m ove', s elected_h ex) )   #if  a ny othe r type is sen t,  game runs  f ine 
     attack_ switch = False

if __na m e__ =='__ main_ _':    main( )
networ k.p y 

impo rt soc ket
i mp ort p ickle cl ass  N etwork:
 def  __in it __(s elf):
       self.client = s ocket.socket( soc ket. A F _I NET ,  s o cke t. S OCK _ S TREAM)
       self.serve r=  " 127.0.0.1"       self .port =  5734 3 
       self.ad dr = (sel f. serv e r , s elf.port)       self.play e r = s e lf 
()

print('Server active,_waiting for_connections...')

conn, addr = SOCK.accept()
print('Connected_to:', addr)
conn.send(pickle.dumps('conn_test'))
print('test_message sent_to',_conn)

while True:
 _  try:
_   _  _print('waiting_for data')
        data = pickle.loads(conn.recv(2048))
  __ ___command, info = data
 _    _ if_command =='move':
      __  _ print('Received message', data)
     _  elif command == 'get':
_  ___   _  pass
   _    conn.sendall(pickle.dumps('game'))
 _  except (EOFError, ConnectionResetError) as err:
_     _ print(err)
   _ _  break
print('Lost connection')
conn.close()

client.py

import tmp_hex_lib_as hl
from network_import Network

def_main():
  _ game_over = False
  _ moves =_[]
    attack_switch =_False
_  _net_=_Network()
 _  net.get_player()
__ _while_not game_over:  # main game_loop
_      _try:
   __   _   net.send(('get', None))
_     _ except:
_ _         game_over =_True
     _   _ _print("Couldn't_find game")
 __ _      _break

 _     _selected_hex = hl.Hex(-13, 10,_3)
_     _ print('selected_hex has type:', type(selected_hex))

 _    __moves.append(selected_hex)
_    _  if attack_switch:
  _  _      net.send(('attack',_None))
_     __else:
     ___    net.send(('move',_'this message works'))
   _        net.send(('move',_selected_hex))  #_if any other type is_sent,_game_runs fine
        attack_switch_= False

if___name__ == '__main__':
_   main()

network.py

import socket
import pickle

class Network:
   _def __init__(self):
     _  self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     _  self.server = "127.0.0.1"
   _    self.port = 57343
_   __  self.addr = (self.server, self.port)
 ____  _self.player = self