probotanki-lib 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- probotanki_lib-2.0.0/MANIFEST.in +13 -0
- probotanki_lib-2.0.0/PKG-INFO +64 -0
- probotanki_lib-2.0.0/README.md +46 -0
- probotanki_lib-2.0.0/__init__.py +2 -0
- probotanki_lib-2.0.0/codec/__init__.py +5 -0
- probotanki_lib-2.0.0/codec/basecodec.py +34 -0
- probotanki_lib-2.0.0/codec/complex/__init__.py +7 -0
- probotanki_lib-2.0.0/codec/complex/doubleintcodec.py +6 -0
- probotanki_lib-2.0.0/codec/complex/jsoncodec.py +14 -0
- probotanki_lib-2.0.0/codec/complex/stringcodec.py +31 -0
- probotanki_lib-2.0.0/codec/complex/vector3dcodec.py +4 -0
- probotanki_lib-2.0.0/codec/complex/vectorshortcodec.py +4 -0
- probotanki_lib-2.0.0/codec/complex/vectorstringcodec.py +4 -0
- probotanki_lib-2.0.0/codec/complex/vectorvector3dcodec.py +4 -0
- probotanki_lib-2.0.0/codec/custom/__init__.py +23 -0
- probotanki_lib-2.0.0/codec/custom/battleimfouserpreviewcodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/battleinfocodec.py +9 -0
- probotanki_lib-2.0.0/codec/custom/battlelimitscodec.py +3 -0
- probotanki_lib-2.0.0/codec/custom/battlenotifiercodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/battleusercodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/battleuserrewardscodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/battleuserstatscodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/chatmessagecodec.py +9 -0
- probotanki_lib-2.0.0/codec/custom/missioncodec.py +11 -0
- probotanki_lib-2.0.0/codec/custom/missionrewardcodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/missionstreakcodec.py +7 -0
- probotanki_lib-2.0.0/codec/custom/movecodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/rankrangecodec.py +3 -0
- probotanki_lib-2.0.0/codec/custom/referraldatacodec.py +11 -0
- probotanki_lib-2.0.0/codec/custom/tankdamagecodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/targethitcodec.py +11 -0
- probotanki_lib-2.0.0/codec/custom/targetpositioncodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/turretrotatecodec.py +7 -0
- probotanki_lib-2.0.0/codec/custom/userstatscodec.py +8 -0
- probotanki_lib-2.0.0/codec/custom/userstatuscodec.py +9 -0
- probotanki_lib-2.0.0/codec/custombasecodec.py +33 -0
- probotanki_lib-2.0.0/codec/factory/__init__.py +7 -0
- probotanki_lib-2.0.0/codec/factory/multitypecodec.py +31 -0
- probotanki_lib-2.0.0/codec/factory/vectorcodec.py +40 -0
- probotanki_lib-2.0.0/codec/primitive/__init__.py +5 -0
- probotanki_lib-2.0.0/codec/primitive/boolcodec.py +10 -0
- probotanki_lib-2.0.0/codec/primitive/bytecodec.py +11 -0
- probotanki_lib-2.0.0/codec/primitive/floatcodec.py +11 -0
- probotanki_lib-2.0.0/codec/primitive/intcodec.py +11 -0
- probotanki_lib-2.0.0/codec/primitive/shortcodec.py +11 -0
- probotanki_lib-2.0.0/modules/__init__.py +0 -0
- probotanki_lib-2.0.0/modules/client/__init__.py +2 -0
- probotanki_lib-2.0.0/modules/client/asynctankiinstance.py +164 -0
- probotanki_lib-2.0.0/modules/client/tankiinstance.py +145 -0
- probotanki_lib-2.0.0/modules/communications/__init__.py +4 -0
- probotanki_lib-2.0.0/modules/communications/abstractmessage.py +13 -0
- probotanki_lib-2.0.0/modules/communications/command.py +30 -0
- probotanki_lib-2.0.0/modules/communications/error.py +31 -0
- probotanki_lib-2.0.0/modules/communications/log.py +21 -0
- probotanki_lib-2.0.0/modules/communications/typeguards.py +16 -0
- probotanki_lib-2.0.0/modules/misc/__init__.py +1 -0
- probotanki_lib-2.0.0/modules/misc/packetmanager.py +45 -0
- probotanki_lib-2.0.0/modules/networking/__init__.py +2 -0
- probotanki_lib-2.0.0/modules/networking/asynctankisocket.py +224 -0
- probotanki_lib-2.0.0/modules/networking/tankisocket.py +166 -0
- probotanki_lib-2.0.0/modules/processing/__init__.py +2 -0
- probotanki_lib-2.0.0/modules/processing/abstractprocessor.py +202 -0
- probotanki_lib-2.0.0/modules/processing/asyncabstractprocessor.py +249 -0
- probotanki_lib-2.0.0/modules/security/__init__.py +2 -0
- probotanki_lib-2.0.0/modules/security/cprotection.c +12094 -0
- probotanki_lib-2.0.0/modules/security/cprotection.cpython-311-darwin.so +0 -0
- probotanki_lib-2.0.0/modules/security/cprotection.pyi +14 -0
- probotanki_lib-2.0.0/modules/security/cprotection.pyx +111 -0
- probotanki_lib-2.0.0/modules/security/protection.py +76 -0
- probotanki_lib-2.0.0/modules/timer/__init__.py +1 -0
- probotanki_lib-2.0.0/modules/timer/tankitimer.py +109 -0
- probotanki_lib-2.0.0/modules/tracker/__init__.py +2 -0
- probotanki_lib-2.0.0/modules/tracker/asyncbasetracker.py +231 -0
- probotanki_lib-2.0.0/modules/tracker/asynctarget.py +63 -0
- probotanki_lib-2.0.0/modules/tracker/basetracker.py +179 -0
- probotanki_lib-2.0.0/modules/tracker/target.py +69 -0
- probotanki_lib-2.0.0/packets/__init__.py +10 -0
- probotanki_lib-2.0.0/packets/abstractpacket.py +78 -0
- probotanki_lib-2.0.0/packets/battle_info/__init__.py +46 -0
- probotanki_lib-2.0.0/packets/battle_info/battlefund.py +9 -0
- probotanki_lib-2.0.0/packets/battle_info/battlepinginfo.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/battlepingsync.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/battletimeleft.py +12 -0
- probotanki_lib-2.0.0/packets/battle_info/changeby.py +9 -0
- probotanki_lib-2.0.0/packets/battle_info/fullyrespawned.py +9 -0
- probotanki_lib-2.0.0/packets/battle_info/goldboxdroptext.py +11 -0
- probotanki_lib-2.0.0/packets/battle_info/initbattlestats.py +14 -0
- probotanki_lib-2.0.0/packets/battle_info/killconfirm.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/leftinsidedmbattle.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/leftinsideteambattle.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/loadnewplayerdm.py +12 -0
- probotanki_lib-2.0.0/packets/battle_info/loadnewplayerteam.py +13 -0
- probotanki_lib-2.0.0/packets/battle_info/playerstartposition.py +9 -0
- probotanki_lib-2.0.0/packets/battle_info/sendrespawn.py +6 -0
- probotanki_lib-2.0.0/packets/battle_info/tankdamage.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/tankhealth.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/updatebattleplayerstatistics.py +9 -0
- probotanki_lib-2.0.0/packets/battle_info/updateteambattlescore.py +10 -0
- probotanki_lib-2.0.0/packets/battle_info/userrewards.py +11 -0
- probotanki_lib-2.0.0/packets/battle_info/userstats.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/__init__.py +41 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/battleusercontrol.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/battleuserteamstats.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/bonusboxdropped.py +11 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/bonusboxexistinglocations.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/changedequipment.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/collectcrybox.py +12 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/collectedbonusbox.py +12 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/deathdelayend.py +6 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/despawnalive.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/effectaftermath.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/endrespfantom.py +6 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/leavebattle.py +12 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/loadbonusboxresources.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/loadcurrentsupplyeffect.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/loadmaplights.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/loadownedgarageitems.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/loadpurchasableitems.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/minelocation.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/mineplace.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/move.py +13 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/movecommand.py +11 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/moved.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/playerequipment.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/playershot.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/rankup.py +13 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/removebonusbox.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/respawndelay.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/selfdestruct.py +6 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/selfdestructed.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/shotdirection.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/shoteffect.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/shoteffectapplied.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/startrespfantom.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/suicidedelay.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/tankmovementinfo.py +10 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/tankstatsynced.py +12 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/turretcontrol.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/turretrotated.py +11 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/turretrotation.py +11 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/usersuppliesinfo.py +9 -0
- probotanki_lib-2.0.0/packets/battle_mechanics/usesupply.py +12 -0
- probotanki_lib-2.0.0/packets/chat/__init__.py +15 -0
- probotanki_lib-2.0.0/packets/chat/receivegamechat.py +10 -0
- probotanki_lib-2.0.0/packets/chat/receivegamesystemchat.py +9 -0
- probotanki_lib-2.0.0/packets/chat/receivelobbychat.py +10 -0
- probotanki_lib-2.0.0/packets/chat/sendgamechat.py +10 -0
- probotanki_lib-2.0.0/packets/chat/sendlobbychat.py +9 -0
- probotanki_lib-2.0.0/packets/chat/wipelobbymessages.py +9 -0
- probotanki_lib-2.0.0/packets/entry/__init__.py +55 -0
- probotanki_lib-2.0.0/packets/entry/answercaptcha.py +11 -0
- probotanki_lib-2.0.0/packets/entry/banned.py +10 -0
- probotanki_lib-2.0.0/packets/entry/captchacorrect.py +10 -0
- probotanki_lib-2.0.0/packets/entry/changelayout.py +10 -0
- probotanki_lib-2.0.0/packets/entry/checknameavailability.py +10 -0
- probotanki_lib-2.0.0/packets/entry/createaccount.py +10 -0
- probotanki_lib-2.0.0/packets/entry/email.py +10 -0
- probotanki_lib-2.0.0/packets/entry/invitecodestatus.py +9 -0
- probotanki_lib-2.0.0/packets/entry/loadaccountstats.py +12 -0
- probotanki_lib-2.0.0/packets/entry/loadfriendslist.py +10 -0
- probotanki_lib-2.0.0/packets/entry/loadmapinfo.py +10 -0
- probotanki_lib-2.0.0/packets/entry/loadnewbierewards.py +11 -0
- probotanki_lib-2.0.0/packets/entry/loadratingstats.py +9 -0
- probotanki_lib-2.0.0/packets/entry/loadresources.py +11 -0
- probotanki_lib-2.0.0/packets/entry/login.py +10 -0
- probotanki_lib-2.0.0/packets/entry/loginfailed.py +6 -0
- probotanki_lib-2.0.0/packets/entry/loginready.py +9 -0
- probotanki_lib-2.0.0/packets/entry/loginsuccess.py +6 -0
- probotanki_lib-2.0.0/packets/entry/nameavailable.py +6 -0
- probotanki_lib-2.0.0/packets/entry/nameunavailable.py +10 -0
- probotanki_lib-2.0.0/packets/entry/receivecaptcha.py +13 -0
- probotanki_lib-2.0.0/packets/entry/requestcaptcha.py +10 -0
- probotanki_lib-2.0.0/packets/entry/resourcesloaded.py +9 -0
- probotanki_lib-2.0.0/packets/entry/setcaptchakeys.py +11 -0
- probotanki_lib-2.0.0/packets/entry/setclientlang.py +10 -0
- probotanki_lib-2.0.0/packets/entry/wrongnewcaptcha.py +13 -0
- probotanki_lib-2.0.0/packets/garage/__init__.py +13 -0
- probotanki_lib-2.0.0/packets/garage/buykit.py +11 -0
- probotanki_lib-2.0.0/packets/garage/buymultipleitems.py +10 -0
- probotanki_lib-2.0.0/packets/garage/checkitemmounted.py +10 -0
- probotanki_lib-2.0.0/packets/garage/loadgarage.py +6 -0
- probotanki_lib-2.0.0/packets/garage/mountitem.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/__init__.py +47 -0
- probotanki_lib-2.0.0/packets/lobby/acceptinvite.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/battlecreated.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/battlekickreason.py +10 -0
- probotanki_lib-2.0.0/packets/lobby/checkbattlename.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/createbattle.py +22 -0
- probotanki_lib-2.0.0/packets/lobby/joinbattle.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/joinedoutsidedmbattle.py +10 -0
- probotanki_lib-2.0.0/packets/lobby/joinedoutsideteambattle.py +11 -0
- probotanki_lib-2.0.0/packets/lobby/joinedselecteddmbattle.py +11 -0
- probotanki_lib-2.0.0/packets/lobby/joinedselectedteambattle.py +12 -0
- probotanki_lib-2.0.0/packets/lobby/leftoutsidedmbattle.py +10 -0
- probotanki_lib-2.0.0/packets/lobby/leftoutsideteambattle.py +10 -0
- probotanki_lib-2.0.0/packets/lobby/leftselectedpreview.py +10 -0
- probotanki_lib-2.0.0/packets/lobby/loadallbattles.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/loadbattleinfo.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/loadlobby.py +6 -0
- probotanki_lib-2.0.0/packets/lobby/openfriendslist.py +6 -0
- probotanki_lib-2.0.0/packets/lobby/receivedinvite.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/rejectinvite.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/removebattle.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/roundfinish.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/roundstart.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/selectbattle.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/sendinvite.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/serverrestart.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/spectatebattle.py +6 -0
- probotanki_lib-2.0.0/packets/lobby/swapteams.py +9 -0
- probotanki_lib-2.0.0/packets/lobby/updateplayerdmbattlepreview.py +11 -0
- probotanki_lib-2.0.0/packets/lobby/updateplayerteambattlepreview.py +11 -0
- probotanki_lib-2.0.0/packets/lobby/updateteambattlepreview.py +11 -0
- probotanki_lib-2.0.0/packets/network/__init__.py +9 -0
- probotanki_lib-2.0.0/packets/network/activateprotection.py +10 -0
- probotanki_lib-2.0.0/packets/network/ping.py +7 -0
- probotanki_lib-2.0.0/packets/network/pong.py +7 -0
- probotanki_lib-2.0.0/packets/others/__init__.py +16 -0
- probotanki_lib-2.0.0/packets/others/acceptmission.py +9 -0
- probotanki_lib-2.0.0/packets/others/battleid.py +9 -0
- probotanki_lib-2.0.0/packets/others/buyfromshop.py +9 -0
- probotanki_lib-2.0.0/packets/others/changefreemission.py +9 -0
- probotanki_lib-2.0.0/packets/others/changemission.py +9 -0
- probotanki_lib-2.0.0/packets/others/changeshoplocation.py +9 -0
- probotanki_lib-2.0.0/packets/others/closesettings.py +9 -0
- probotanki_lib-2.0.0/packets/others/completedmission.py +9 -0
- probotanki_lib-2.0.0/packets/others/loadmissions.py +9 -0
- probotanki_lib-2.0.0/packets/others/loadreferral.py +6 -0
- probotanki_lib-2.0.0/packets/others/loadsettings.py +6 -0
- probotanki_lib-2.0.0/packets/others/notification.py +9 -0
- probotanki_lib-2.0.0/packets/others/referraldata.py +14 -0
- probotanki_lib-2.0.0/packets/others/shopinfo.py +9 -0
- probotanki_lib-2.0.0/packets/others/showmissions.py +11 -0
- probotanki_lib-2.0.0/packets/others/shownewmission.py +13 -0
- probotanki_lib-2.0.0/packets/shop/__init__.py +9 -0
- probotanki_lib-2.0.0/packets/shop/promocodefailed.py +6 -0
- probotanki_lib-2.0.0/packets/shop/promocodesuccess.py +6 -0
- probotanki_lib-2.0.0/packets/shop/sendpromocode.py +9 -0
- probotanki_lib-2.0.0/packets/status/__init__.py +15 -0
- probotanki_lib-2.0.0/packets/status/inbattlestatus.py +10 -0
- probotanki_lib-2.0.0/packets/status/notinbattlestatus.py +10 -0
- probotanki_lib-2.0.0/packets/status/onlinestatus.py +11 -0
- probotanki_lib-2.0.0/packets/status/premiumstatus.py +11 -0
- probotanki_lib-2.0.0/packets/status/rankstatus.py +11 -0
- probotanki_lib-2.0.0/packets/status/subscribestatus.py +11 -0
- probotanki_lib-2.0.0/packets/turrets/__init__.py +20 -0
- probotanki_lib-2.0.0/packets/turrets/firedamage.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/fireendout.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/firestartout.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/freezeendout.py +9 -0
- probotanki_lib-2.0.0/packets/turrets/freezestartout.py +9 -0
- probotanki_lib-2.0.0/packets/turrets/hammershotout.py +15 -0
- probotanki_lib-2.0.0/packets/turrets/multishotturretin.py +14 -0
- probotanki_lib-2.0.0/packets/turrets/multishotturretout.py +15 -0
- probotanki_lib-2.0.0/packets/turrets/railgunshotinitout.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/railgunshotout.py +12 -0
- probotanki_lib-2.0.0/packets/turrets/shaftarcadeout.py +12 -0
- probotanki_lib-2.0.0/packets/turrets/shaftscopeinitout.py +13 -0
- probotanki_lib-2.0.0/packets/turrets/shaftscopeout.py +12 -0
- probotanki_lib-2.0.0/packets/turrets/smokeyshootairout.py +9 -0
- probotanki_lib-2.0.0/packets/turrets/smokeyshootwallout.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/smokyshoottargetout.py +11 -0
- probotanki_lib-2.0.0/packets/turrets/smokyshotin.py +10 -0
- probotanki_lib-2.0.0/packets/turrets/syncturretdata.py +9 -0
- probotanki_lib-2.0.0/packets/turrets/vulcanendout.py +12 -0
- probotanki_lib-2.0.0/packets/turrets/vulcanstartout.py +12 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/PKG-INFO +64 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/SOURCES.txt +557 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/dependency_links.txt +1 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/not-zip-safe +1 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/requires.txt +2 -0
- probotanki_lib-2.0.0/probotanki_lib.egg-info/top_level.txt +1 -0
- probotanki_lib-2.0.0/pyproject.toml +29 -0
- probotanki_lib-2.0.0/requirements.txt +2 -0
- probotanki_lib-2.0.0/setup.cfg +4 -0
- probotanki_lib-2.0.0/setup.py +48 -0
- probotanki_lib-2.0.0/utils/__init__.py +4 -0
- probotanki_lib-2.0.0/utils/address.py +19 -0
- probotanki_lib-2.0.0/utils/ebytearray.py +77 -0
- probotanki_lib-2.0.0/utils/enums/__init__.py +6 -0
- probotanki_lib-2.0.0/utils/enums/autoenum.py +9 -0
- probotanki_lib-2.0.0/utils/enums/compare.py +5 -0
- probotanki_lib-2.0.0/utils/enums/layout.py +9 -0
- probotanki_lib-2.0.0/utils/enums/logchanneltype.py +9 -0
- probotanki_lib-2.0.0/utils/enums/message.py +8 -0
- probotanki_lib-2.0.0/utils/normalizer.py +3 -0
- probotanki_lib-2.0.0/utils/reconnectionconfig.py +21 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include requirements.txt
|
|
3
|
+
graft modules
|
|
4
|
+
graft packets
|
|
5
|
+
graft utils
|
|
6
|
+
graft codec
|
|
7
|
+
|
|
8
|
+
# Include all Cython and interface files
|
|
9
|
+
global-include *.pyx *.pxd *.pyi
|
|
10
|
+
|
|
11
|
+
# Exclude common unwanted files
|
|
12
|
+
prune */__pycache__
|
|
13
|
+
global-exclude *.py[co]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: probotanki-lib
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Core library for ProboTanki providing networking modules and packet handling utilities.
|
|
5
|
+
Author-email: Teinc3 <teinc3@gmail.com>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/Teinc3/ProboTanki-Lib
|
|
8
|
+
Project-URL: Documentation, https://deepwiki.com/Teinc3/ProboTanki-Lib
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/Teinc3/ProboTanki-Lib/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
Requires-Dist: pysocks
|
|
16
|
+
Requires-Dist: aiosocks
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
|
|
19
|
+
# ProboTanki-Lib
|
|
20
|
+
[](https://github.com/Teinc3/ProboTanki-Lib/releases/latest)
|
|
21
|
+
[](https://deepwiki.com/Teinc3/ProboTanki-Lib)
|
|
22
|
+
|
|
23
|
+
A core library for ProboTanki providing networking modules and packet handling utilities.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
This library is not available on PyPI and cannot be installed from there.
|
|
27
|
+
|
|
28
|
+
To install it, clone the repository to a local directory in your project.
|
|
29
|
+
```bash
|
|
30
|
+
cd /path/to/your/project
|
|
31
|
+
mkdir -p pbtlib
|
|
32
|
+
git clone https://github.com/Teinc3/ProboTanki-Lib.git
|
|
33
|
+
```
|
|
34
|
+
*OR*
|
|
35
|
+
```bash
|
|
36
|
+
git clone git@github.com:Teinc3/ProboTanki-Lib.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then, add the path to your requirements:
|
|
40
|
+
```pip-requirements
|
|
41
|
+
./pbtlib
|
|
42
|
+
|
|
43
|
+
# Other requirements you might need...
|
|
44
|
+
```
|
|
45
|
+
*OR*
|
|
46
|
+
```bash
|
|
47
|
+
pip install ./pbtlib
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This will install the library in your Python environment.
|
|
51
|
+
|
|
52
|
+
If you would like to develop a fork of the library alongside your project,
|
|
53
|
+
you can also install the package in *Editable Mode*:
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e ./pbtlib
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## License and Contributing
|
|
59
|
+
This library is not licensed as it is subject to the terms of ProTanki Online.
|
|
60
|
+
|
|
61
|
+
If you want to contribute to this library, please fork the repository and create a pull request with your changes.
|
|
62
|
+
Please make sure to follow the coding style and conventions used in the library.
|
|
63
|
+
|
|
64
|
+
If you have any questions or suggestions, feel free to open an issue in the repository.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ProboTanki-Lib
|
|
2
|
+
[](https://github.com/Teinc3/ProboTanki-Lib/releases/latest)
|
|
3
|
+
[](https://deepwiki.com/Teinc3/ProboTanki-Lib)
|
|
4
|
+
|
|
5
|
+
A core library for ProboTanki providing networking modules and packet handling utilities.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
This library is not available on PyPI and cannot be installed from there.
|
|
9
|
+
|
|
10
|
+
To install it, clone the repository to a local directory in your project.
|
|
11
|
+
```bash
|
|
12
|
+
cd /path/to/your/project
|
|
13
|
+
mkdir -p pbtlib
|
|
14
|
+
git clone https://github.com/Teinc3/ProboTanki-Lib.git
|
|
15
|
+
```
|
|
16
|
+
*OR*
|
|
17
|
+
```bash
|
|
18
|
+
git clone git@github.com:Teinc3/ProboTanki-Lib.git
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then, add the path to your requirements:
|
|
22
|
+
```pip-requirements
|
|
23
|
+
./pbtlib
|
|
24
|
+
|
|
25
|
+
# Other requirements you might need...
|
|
26
|
+
```
|
|
27
|
+
*OR*
|
|
28
|
+
```bash
|
|
29
|
+
pip install ./pbtlib
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This will install the library in your Python environment.
|
|
33
|
+
|
|
34
|
+
If you would like to develop a fork of the library alongside your project,
|
|
35
|
+
you can also install the package in *Editable Mode*:
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e ./pbtlib
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License and Contributing
|
|
41
|
+
This library is not licensed as it is subject to the terms of ProTanki Online.
|
|
42
|
+
|
|
43
|
+
If you want to contribute to this library, please fork the repository and create a pull request with your changes.
|
|
44
|
+
Please make sure to follow the coding style and conventions used in the library.
|
|
45
|
+
|
|
46
|
+
If you have any questions or suggestions, feel free to open an issue in the repository.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import TypeVar, Generic, Any
|
|
3
|
+
|
|
4
|
+
from ..utils import EByteArray
|
|
5
|
+
|
|
6
|
+
T = TypeVar("T", bound=Any)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseCodec(ABC, Generic[T]):
|
|
10
|
+
"""
|
|
11
|
+
Base "Interface" for all codecs, whether primitive or complex
|
|
12
|
+
|
|
13
|
+
Type: Generic[T] (T is bound to Any, but can be specified for less complex codecs)
|
|
14
|
+
|
|
15
|
+
Static Methods:
|
|
16
|
+
- decode: Decodes a value from an ebytearray
|
|
17
|
+
- encode: Encodes a value to an ebytearray
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
boolshortern = False
|
|
21
|
+
|
|
22
|
+
def __init__(self, buffer: EByteArray):
|
|
23
|
+
self._buffer = buffer
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def decode(self) -> T:
|
|
27
|
+
raise NotImplementedError()
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def encode(self, value: T) -> int:
|
|
31
|
+
"""
|
|
32
|
+
Encodes a value to an ebytearray and returns the number of bytes written
|
|
33
|
+
"""
|
|
34
|
+
raise NotImplementedError()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from .doubleintcodec import DoubleIntCodecFactory
|
|
2
|
+
from .stringcodec import StringCodec
|
|
3
|
+
from .jsoncodec import JsonCodec
|
|
4
|
+
from .vector3dcodec import Vector3DCodec
|
|
5
|
+
from .vectorshortcodec import VectorShortCodec
|
|
6
|
+
from .vectorstringcodec import VectorStringCodec
|
|
7
|
+
from .vectorvector3dcodec import VectorVector3DCodec
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from .stringcodec import StringCodec
|
|
4
|
+
from ..basecodec import BaseCodec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class JsonCodec(BaseCodec[dict]):
|
|
8
|
+
"""Codec for JSON objects"""
|
|
9
|
+
|
|
10
|
+
def decode(self):
|
|
11
|
+
return json.loads(StringCodec(self._buffer).decode())
|
|
12
|
+
|
|
13
|
+
def encode(self, value):
|
|
14
|
+
return StringCodec(self._buffer).encode(json.dumps(value, separators=(',', ':')))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from ..basecodec import BaseCodec
|
|
2
|
+
from ...utils import EByteArray
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class StringCodec(BaseCodec[str]):
|
|
6
|
+
"""
|
|
7
|
+
Codec for string values.
|
|
8
|
+
|
|
9
|
+
1 Byte - Is string empty?
|
|
10
|
+
(If empty, everything else is ignored)
|
|
11
|
+
4 Bytes - String length
|
|
12
|
+
Remaining Bytes - String value
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def decode(self):
|
|
16
|
+
is_empty = self._buffer.read_boolean()
|
|
17
|
+
if is_empty:
|
|
18
|
+
return ""
|
|
19
|
+
length = self._buffer.read_int()
|
|
20
|
+
return self._buffer.read_string(length)
|
|
21
|
+
|
|
22
|
+
def encode(self, value):
|
|
23
|
+
self._buffer.write_boolean(not value)
|
|
24
|
+
if not value:
|
|
25
|
+
return 1
|
|
26
|
+
# NOTE: len() returns the length of the string in CHARS NOT BYTES!!!
|
|
27
|
+
string_buffer = EByteArray().write_string(value)
|
|
28
|
+
string_buffer_len = len(string_buffer)
|
|
29
|
+
self._buffer.write_int(string_buffer_len)
|
|
30
|
+
self._buffer.write(string_buffer)
|
|
31
|
+
return 1 + 4 + string_buffer_len
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Again, only use the imports from this file externally
|
|
2
|
+
# Internally, juse reference the file directly.
|
|
3
|
+
|
|
4
|
+
from .battleinfocodec import BattleInfoCodec
|
|
5
|
+
from .battleimfouserpreviewcodec import BattleInfoUserCodec
|
|
6
|
+
from .battleusercodec import BattleUserCodec
|
|
7
|
+
from .battlelimitscodec import BattleLimitsCodec
|
|
8
|
+
from .battlenotifiercodec import BattleNotifierCodec
|
|
9
|
+
from .battleuserrewardscodec import BattleUserRewardsCodec
|
|
10
|
+
from .battleuserstatscodec import BattleUserStatsCodec
|
|
11
|
+
from .chatmessagecodec import ChatMessageCodec
|
|
12
|
+
from .missioncodec import MissionCodec
|
|
13
|
+
from .missionrewardcodec import MissionRewardCodec
|
|
14
|
+
from .missionstreakcodec import MissionStreakCodec
|
|
15
|
+
from .movecodec import MoveCodec
|
|
16
|
+
from .rankrangecodec import RankRangeCodec
|
|
17
|
+
from .tankdamagecodec import TankDamageCodec
|
|
18
|
+
from .targethitcodec import TargetHitCodec
|
|
19
|
+
from .targetpositioncodec import TargetPositionCodec
|
|
20
|
+
from .turretrotatecodec import TurretRotateCodec
|
|
21
|
+
from .userstatscodec import UserStatsCodec
|
|
22
|
+
from .userstatuscodec import UserStatusCodec
|
|
23
|
+
from .referraldatacodec import ReferralDataCodec
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import BoolCodec, IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BattleInfoUserCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["kills", "score", "suspicious", "user"]
|
|
8
|
+
codecs = [IntCodec, IntCodec, BoolCodec, StringCodec]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import BoolCodec, IntCodec
|
|
4
|
+
from .rankrangecodec import RankRangeCodec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BattleInfoCodec(CustomBaseCodec):
|
|
8
|
+
attributes = ["battleID", "mapName", "mode", "private", "proBattle", "range", "serverNumber"]
|
|
9
|
+
codecs = [StringCodec, StringCodec, IntCodec, BoolCodec, BoolCodec, RankRangeCodec, IntCodec]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import IntCodec, ByteCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BattleUserCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ['modLevel', 'deaths', 'kills', 'rank', 'score', 'username']
|
|
8
|
+
codecs = [IntCodec, IntCodec, IntCodec, ByteCodec, IntCodec, StringCodec]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BattleUserRewardsCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["newbiesAbonementBonusReward", "premiumBonusReward", "reward", "userid"]
|
|
8
|
+
codecs = [IntCodec, IntCodec, IntCodec, StringCodec]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BattleUserStatsCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["deaths", "kills", "score", "user"]
|
|
8
|
+
codecs = [IntCodec, IntCodec, IntCodec, StringCodec]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import BoolCodec
|
|
4
|
+
from .userstatuscodec import UserStatusCodec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ChatMessageCodec(CustomBaseCodec):
|
|
8
|
+
attributes = ["authorStatus", "systemMessage", "targetStatus", "message", "warning"]
|
|
9
|
+
codecs = [UserStatusCodec, BoolCodec, UserStatusCodec, StringCodec, BoolCodec]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..factory import VectorCodecFactory
|
|
4
|
+
from ..primitive import BoolCodec, IntCodec
|
|
5
|
+
from .missionrewardcodec import MissionRewardCodec
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MissionCodec(CustomBaseCodec):
|
|
9
|
+
attributes = ["freeChange", "description", "threshold", "image", "rewards", "progress", "missionID", "changeCost"]
|
|
10
|
+
codecs = [BoolCodec, StringCodec, IntCodec, IntCodec, VectorCodecFactory(dict, MissionRewardCodec), IntCodec,
|
|
11
|
+
IntCodec, IntCodec]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..primitive import IntCodec, BoolCodec
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MissionStreakCodec(CustomBaseCodec):
|
|
6
|
+
attributes = ["level", "streak", "doneToday", "questImgID", "rewardImgID"]
|
|
7
|
+
codecs = [IntCodec, IntCodec, BoolCodec, IntCodec, IntCodec]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import Vector3DCodec
|
|
3
|
+
from ..primitive import ByteCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MoveCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["angV", "control", "linV", "orientation", "pos"]
|
|
8
|
+
codecs = [Vector3DCodec, ByteCodec, Vector3DCodec, Vector3DCodec, Vector3DCodec]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..primitive import IntCodec
|
|
3
|
+
from ..complex import StringCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ReferralDataCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ['income', 'username']
|
|
8
|
+
codecs = [IntCodec, StringCodec]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__all__ = ['ReferralDataCodec']
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import FloatCodec, IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TankDamageCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["damage", "damageType", "target"]
|
|
8
|
+
codecs = [FloatCodec, IntCodec, StringCodec]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import Vector3DCodec, StringCodec
|
|
3
|
+
from ..primitive import ByteCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TargetHitCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ['direction', 'localHitPoint', 'numberOfHits', 'target']
|
|
8
|
+
codecs = [Vector3DCodec, Vector3DCodec, ByteCodec, StringCodec]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__all__ = ['TargetHitCodec']
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import Vector3DCodec, StringCodec
|
|
3
|
+
from ..primitive import FloatCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TargetPositionCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ['localHitPoint', 'orientation', 'position', 'target', 'turretAngle']
|
|
8
|
+
codecs = [Vector3DCodec, Vector3DCodec, Vector3DCodec, StringCodec, FloatCodec]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UserStatsCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ["deaths", "kills", "score", "username"]
|
|
8
|
+
codecs = [IntCodec, IntCodec, IntCodec, StringCodec]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from ..custombasecodec import CustomBaseCodec
|
|
2
|
+
from ..complex import StringCodec
|
|
3
|
+
from ..primitive import IntCodec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UserStatusCodec(CustomBaseCodec):
|
|
7
|
+
attributes = ['modLevel', 'ip', 'rank', 'username']
|
|
8
|
+
codecs = [IntCodec, StringCodec, IntCodec, StringCodec]
|
|
9
|
+
boolshortern = True
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import Type, ClassVar
|
|
2
|
+
|
|
3
|
+
from .basecodec import BaseCodec
|
|
4
|
+
from .primitive import BoolCodec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CustomBaseCodec(BaseCodec[dict]):
|
|
8
|
+
attributes: ClassVar[list[str]] = []
|
|
9
|
+
codecs: ClassVar[list[Type[BaseCodec]]] = []
|
|
10
|
+
|
|
11
|
+
# Override these methods if necessary
|
|
12
|
+
def decode(self):
|
|
13
|
+
obj = {}
|
|
14
|
+
if self.boolshortern and BoolCodec(self._buffer).decode():
|
|
15
|
+
return obj
|
|
16
|
+
|
|
17
|
+
for i in range(len(self.codecs)):
|
|
18
|
+
attribute_name = self.attributes[i]
|
|
19
|
+
codec_instance = self.codecs[i](self._buffer)
|
|
20
|
+
decoded_value = codec_instance.decode()
|
|
21
|
+
obj[attribute_name] = decoded_value
|
|
22
|
+
return obj
|
|
23
|
+
|
|
24
|
+
def encode(self, value):
|
|
25
|
+
data_len = 0
|
|
26
|
+
if self.boolshortern:
|
|
27
|
+
data_len += BoolCodec(self._buffer).encode(not value)
|
|
28
|
+
if not value:
|
|
29
|
+
return data_len
|
|
30
|
+
|
|
31
|
+
for i in range(len(self.codecs)):
|
|
32
|
+
data_len += self.codecs[i](self._buffer).encode(value[self.attributes[i]])
|
|
33
|
+
return data_len
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from typing import Type
|
|
2
|
+
|
|
3
|
+
from ..basecodec import BaseCodec
|
|
4
|
+
from ..primitive import BoolCodec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def MultiTypeCodecFactory(attributes: list[str], element_codec: Type[BaseCodec], param_boolshortern=False):
|
|
8
|
+
class MultiTypeCodec(BaseCodec[dict]):
|
|
9
|
+
boolshortern = param_boolshortern
|
|
10
|
+
|
|
11
|
+
def decode(self):
|
|
12
|
+
obj = {}
|
|
13
|
+
if self.boolshortern and BoolCodec(self._buffer).decode():
|
|
14
|
+
return obj
|
|
15
|
+
for attribute in attributes:
|
|
16
|
+
obj[attribute] = element_codec(self._buffer).decode()
|
|
17
|
+
return obj
|
|
18
|
+
|
|
19
|
+
def encode(self, value):
|
|
20
|
+
data_len = 0
|
|
21
|
+
if self.boolshortern:
|
|
22
|
+
data_len += BoolCodec(self._buffer).encode(not value)
|
|
23
|
+
if not value:
|
|
24
|
+
return data_len
|
|
25
|
+
for attribute in attributes:
|
|
26
|
+
data_len += element_codec(self._buffer).encode(value[attribute])
|
|
27
|
+
return data_len
|
|
28
|
+
|
|
29
|
+
type_name = element_codec.__name__.replace("Codec", "").capitalize()
|
|
30
|
+
MultiTypeCodec.__name__ = f"Multi{type_name}Codec[{len(attributes)}]"
|
|
31
|
+
return MultiTypeCodec
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing import Type, TypeVar, Generic
|
|
2
|
+
|
|
3
|
+
from ..basecodec import BaseCodec
|
|
4
|
+
from ..primitive import IntCodec, BoolCodec
|
|
5
|
+
|
|
6
|
+
T = TypeVar('T')
|
|
7
|
+
C = TypeVar('C', bound=BaseCodec)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AbstractVectorCodec(BaseCodec[list[T]], Generic[T, C]):
|
|
11
|
+
codec: Type[C]
|
|
12
|
+
|
|
13
|
+
def decode(self) -> list[T]:
|
|
14
|
+
if self.boolshortern and BoolCodec(self._buffer).decode():
|
|
15
|
+
return []
|
|
16
|
+
|
|
17
|
+
list_len = IntCodec(self._buffer).decode()
|
|
18
|
+
return [self.codec(self._buffer).decode() for _ in range(list_len)]
|
|
19
|
+
|
|
20
|
+
def encode(self, value: list[T]) -> int:
|
|
21
|
+
bytes_written = 0
|
|
22
|
+
if self.boolshortern:
|
|
23
|
+
bytes_written += BoolCodec(self._buffer).encode(len(value) == 0)
|
|
24
|
+
if len(value) == 0:
|
|
25
|
+
return bytes_written
|
|
26
|
+
|
|
27
|
+
bytes_written += IntCodec(self._buffer).encode(len(value))
|
|
28
|
+
for item in value:
|
|
29
|
+
bytes_written += self.codec(self._buffer).encode(item)
|
|
30
|
+
return bytes_written
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def VectorCodecFactory(element_type: Type[T], element_codec: Type[C], param_boolshortern=False) -> Type[
|
|
34
|
+
AbstractVectorCodec[T, C]]:
|
|
35
|
+
class VectorCodec(AbstractVectorCodec[T, C]):
|
|
36
|
+
codec = element_codec
|
|
37
|
+
boolshortern = param_boolshortern
|
|
38
|
+
|
|
39
|
+
VectorCodec.__name__ = f"VectorCodec[{element_type.__name__}, {element_codec.__name__}]"
|
|
40
|
+
return VectorCodec
|