Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
65 / 65
100.00% covered (success)
100.00%
23 / 23
CRAP
100.00% covered (success)
100.00%
1 / 1
MessageGenerator
100.00% covered (success)
100.00%
65 / 65
100.00% covered (success)
100.00%
23 / 23
23
100.00% covered (success)
100.00%
1 / 1
 moveToArea
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 domainPolicy
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 loginReponded
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 exitArea
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 moveTowards
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 loadInventory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 logout
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 afk
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 alreadyInArea
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 monstersDetected
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 monstersDetectedOutOfOrder
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 monstersDetectedWithOrphanMondef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 areaMemberOnly
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 monstersDetectedWithoutMonDef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 areaNotAvailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 areaLocked
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 questLoaded
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 questLoadedWithTagsAndRequirements
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 questLoadedWithStaffAndGuildTags
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 equipItem
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 equipItemWithoutBoost
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 unequipItem
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 playerPreferencesLoaded
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace AqwSocketClient\Helpers;
6
7use AqwSocketClient\Enums\EquipmentSlot;
8use AqwSocketClient\Objects\Identifiers\AreaIdentifier;
9use AqwSocketClient\Objects\Identifiers\ItemIdentifier;
10use AqwSocketClient\Objects\Identifiers\SocketIdentifier;
11use AqwSocketClient\Objects\Names\AreaName;
12use AqwSocketClient\Objects\Names\PlayerName;
13
14/**
15 * Pre-built valids AQW server messages.
16 * @mago-ignore lint:too-many-methods
17 */
18final class MessageGenerator
19{
20    public static function moveToArea(AreaName $areaName, AreaIdentifier $areaIdentifier): string
21    {
22        return (
23            '{"t":"xt","b":{"r":-1,"o":{"cmd":"moveToArea","areaName":"'
24            . (string) $areaName
25            . '-1","uoBranch":[],"strMapFileName":"Battleon/town-Battleon-7Nov25r1.swf","intType":"2","monBranch":[],"mondef":[],"areaId":'
26            . (string) $areaIdentifier
27            . ',"strMapName":"'
28            . (string) $areaName
29            . '"}}}'
30        );
31    }
32
33    public static function domainPolicy(): string
34    {
35        return "<cross-domain-policy><allow-access-from domain='*' to-ports='5588' /></cross-domain-policy>";
36    }
37
38    public static function loginReponded(PlayerName $playerName, SocketIdentifier $socketIdentifier): string
39    {
40        return (
41            '%xt%loginResponse%-1%true%'
42            . (string) $socketIdentifier
43            . '%'
44            . (string) $playerName
45            . '%%2026-02-26T19:33:21%sNews=1078,sMap=news/Map-UI_r38.swf,sBook=news/spiderbook3.swf,sAssets=Assets_20251205.swf,gMenu=dynamic-gameMenu-17Jan22.swf,sVersion=R0039,QSInfo=519,iMaxBagSlots=500,iMaxBankSlots=900,iMaxHouseSlots=300,iMaxGuildMembers=800,iMaxFriends=300,iMaxLoadoutSlots=50%3.0141%'
46        );
47    }
48
49    public static function exitArea(PlayerName $playerName): string
50    {
51        return '%xt%exitArea%-1%1128%' . (string) $playerName . '%';
52    }
53
54    public static function moveTowards(PlayerName $playerName): string
55    {
56        return (
57            '%xt%uotls%-1%'
58            . (string) $playerName
59            . '%mvts:-1,px:500,py:375,strPad:Spawn,bResting:false,mvtd:0,tx:0,ty:0,strFrame:Enter%'
60        );
61    }
62
63    public static function loadInventory(): string
64    {
65        return '{"t":"xt","b":{"r":-1,"o":{"bankCount":57,"cmd":"loadInventoryBig","items":[]}}}';
66    }
67
68    public static function logout(): string
69    {
70        return "<msg t='sys'><body action='logout' r='0'></body></msg>";
71    }
72
73    public static function afk(): string
74    {
75        return '%xt%server%-1%Your status is now Away From Keyboard (AFK).%';
76    }
77
78    public static function alreadyInArea(): string
79    {
80        return '%xt%warning%-1%Cannot join a room you are already in.%';
81    }
82
83    public static function monstersDetected(): string
84    {
85        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"moveToArea","areaName":"lair-5999","uoBranch":[],"strMapFileName":"Lair/town-Lair-29Dec24.swf","mondef":[{"sRace":"Dragonkin","MonID":"14","intLevel":25,"strLinkage":"Dragon1","strMonName":"Red Dragon","strMonFileName":"Dragon1.swf","strBehave":"walk"}],"intType":"1","monBranch":[{"intHPMax":30000,"iLvl":25,"MonMapID":14,"MonID":"14","intMP":100,"wDPS":13,"intState":1,"intMPMax":100,"bRed":"0","intHP":30000}],"sExtra":"","monmap":[],"areaId":311032,"strMapName":"lair"}}}';
86    }
87
88    public static function monstersDetectedOutOfOrder(): string
89    {
90        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"moveToArea","areaName":"lair-5999","uoBranch":[],"strMapFileName":"Lair/town-Lair-29Dec24.swf","mondef":[{"sRace":"Dragonkin","MonID":"14","intLevel":25,"strLinkage":"Dragon1","strMonName":"Red Dragon","strMonFileName":"Dragon1.swf","strBehave":"walk"},{"sRace":"Undead","MonID":"7","intLevel":10,"strLinkage":"Zombie1","strMonName":"Zombie","strMonFileName":"Zombie1.swf","strBehave":"walk"}],"intType":"1","monBranch":[{"intHPMax":5000,"iLvl":10,"MonMapID":7,"MonID":"7","intMP":50,"wDPS":5,"intState":1,"intMPMax":50,"bRed":"0","intHP":5000},{"intHPMax":30000,"iLvl":25,"MonMapID":14,"MonID":"14","intMP":100,"wDPS":13,"intState":1,"intMPMax":100,"bRed":"0","intHP":30000}],"sExtra":"","monmap":[],"areaId":311032,"strMapName":"lair"}}}';
91    }
92
93    public static function monstersDetectedWithOrphanMondef(): string
94    {
95        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"moveToArea","areaName":"lair-5999","uoBranch":[],"strMapFileName":"Lair/town-Lair-29Dec24.swf","mondef":[{"sRace":"Dragonkin","MonID":"14","intLevel":25,"strLinkage":"Dragon1","strMonName":"Red Dragon","strMonFileName":"Dragon1.swf","strBehave":"walk"},{"sRace":"Undead","MonID":"7","intLevel":10,"strLinkage":"Zombie1","strMonName":"Zombie","strMonFileName":"Zombie1.swf","strBehave":"walk"}],"intType":"1","monBranch":[{"intHPMax":30000,"iLvl":25,"MonMapID":14,"MonID":"14","intMP":100,"wDPS":13,"intState":1,"intMPMax":100,"bRed":"0","intHP":30000}],"sExtra":"","monmap":[],"areaId":311032,"strMapName":"lair"}}}';
96    }
97
98    public static function areaMemberOnly(): string
99    {
100        return '%xt%warning%-1%"ancienttrigoras" is an Membership-Only Map.%';
101    }
102
103    public static function monstersDetectedWithoutMonDef(): string
104    {
105        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"moveToArea","areaName":"lair-5999","uoBranch":[],"strMapFileName":"Lair/town-Lair-29Dec24.swf","intType":"1","monBranch":[{"intHPMax":30000,"iLvl":25,"MonMapID":14,"MonID":"14","intMP":100,"wDPS":13,"intState":1,"intMPMax":100,"bRed":"0","intHP":30000}],"sExtra":"","monmap":[],"areaId":311032,"strMapName":"lair"}}}';
106    }
107
108    public static function areaNotAvailable(): string
109    {
110        return '%xt%warning%-1%"cetoleonwar" is not available.%';
111    }
112
113    public static function areaLocked(): string
114    {
115        return '%xt%warning%-1%"caroling" map is locked until event begins. Get \'Portal to Frostval Event\' house item from /BaseCamp to unlock.%';
116    }
117
118    public static function questLoaded(): string
119    {
120        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"getQuests","quests":{"868":{"QuestID":868,"sName":"Nulgath (Rare)","sDesc":"Bring me some Mana Energy from the Mana Golem.","sEndText":"AND I\'ve raised your chance of winning!","iExp":300,"iGold":13000,"iRep":300,"FactionID":4,"sFaction":"Evil","iLvl":0,"iReqRep":0,"iReqCP":0,"iClass":0,"bOnce":0,"bUpg":0,"bStaff":0,"bGuild":0,"turnin":[{"ItemID":15385,"QuestID":868,"iQty":5}],"reward":[{"iRate":10,"ItemID":4861,"QuestID":868,"iType":1,"iQty":1}],"reqd":[]}}}}}';
121    }
122
123    public static function questLoadedWithTagsAndRequirements(): string
124    {
125        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"getQuests","quests":{"7165":{"QuestID":7165,"sName":"Member Quest","sDesc":"A quest for members only.","sEndText":"Well done!","iExp":500,"iGold":1000,"iRep":0,"FactionID":1,"sFaction":"Good","iLvl":30,"iReqRep":5,"iReqCP":10,"iClass":42,"bOnce":1,"bUpg":1,"bStaff":0,"bGuild":0,"turnin":[],"reward":[],"reqd":[]}}}}}';
126    }
127
128    public static function questLoadedWithStaffAndGuildTags(): string
129    {
130        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"getQuests","quests":{"9999":{"QuestID":9999,"sName":"Staff Guild Quest","sDesc":"A staff guild quest.","sEndText":"Done!","iExp":0,"iGold":0,"iRep":0,"FactionID":1,"sFaction":"Good","iLvl":0,"iReqRep":0,"iReqCP":0,"iClass":0,"bOnce":0,"bUpg":0,"bStaff":1,"bGuild":1,"turnin":[],"reward":[],"reqd":[]}}}}}';
131    }
132
133    public static function equipItem(SocketIdentifier $socketId, ItemIdentifier $itemId, EquipmentSlot $slot): string
134    {
135        return (
136            '{"t":"xt","b":{"r":-1,"o":{"cmd":"equipItem","uid":'
137            . (string) $socketId
138            . ',"ItemID":'
139            . (string) $itemId
140            . ',"strES":"'
141            . $slot->value
142            . '","sFile":"items/equip/armor.swf","sLink":"http://game.aq.com/","sMeta":"AutoAdd"}}}'
143        );
144    }
145
146    public static function equipItemWithoutBoost(
147        SocketIdentifier $socketId,
148        ItemIdentifier $itemId,
149        EquipmentSlot $slot,
150    ): string {
151        return (
152            '{"t":"xt","b":{"r":-1,"o":{"cmd":"equipItem","uid":'
153            . (string) $socketId
154            . ',"ItemID":'
155            . (string) $itemId
156            . ',"strES":"'
157            . $slot->value
158            . '","sFile":"items/equip/armor.swf","sLink":"http://game.aq.com/"}}}'
159        );
160    }
161
162    public static function unequipItem(SocketIdentifier $socketId, ItemIdentifier $itemId, EquipmentSlot $slot): string
163    {
164        return (
165            '{"t":"xt","b":{"r":-1,"o":{"cmd":"unequipItem","uid":'
166            . (string) $socketId
167            . ',"ItemID":'
168            . (string) $itemId
169            . ',"strES":"'
170            . $slot->value
171            . '","bUnload":true}}}'
172        );
173    }
174
175    public static function playerPreferencesLoaded(): string
176    {
177        return '{"t":"xt","b":{"r":-1,"o":{"cmd":"loadPrefs","result":{"costumes":{"co":83965,"ba":59470,"Weapon":59471,"he":74726},"loadouts":{},"prefs":{}},"success":true}}}';
178    }
179}