| | 1073 | def CmdCheckWealth(mob, args): |
|---|
| | 1074 | # Check if there is a target available. |
|---|
| | 1075 | if not mob.target: |
|---|
| | 1076 | mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ |
|---|
| | 1077 | "This command requires a target.\\n") |
|---|
| | 1078 | return |
|---|
| | 1079 | |
|---|
| | 1080 | # Get a handle to the targets player. |
|---|
| | 1081 | tplayer = mob.target.player |
|---|
| | 1082 | |
|---|
| | 1083 | # Query the targets wealth. |
|---|
| | 1084 | ext = ('pp','gp','sp','cp','tp') |
|---|
| | 1085 | worthLight = (tplayer.lightPlatinum,tplayer.lightGold,tplayer.lightSilver, \ |
|---|
| | 1086 | tplayer.lightCopper,tplayer.lightTin) |
|---|
| | 1087 | lightString = ', '.join('%i%s'%(w,ext[i]) \ |
|---|
| | 1088 | for i,w in enumerate(worthLight) if w != 0) |
|---|
| | 1089 | worthDarkness = (tplayer.darknessPlatinum,tplayer.darknessGold, \ |
|---|
| | 1090 | tplayer.darknessSilver,tplayer.darknessCopper,tplayer.darknessTin) |
|---|
| | 1091 | darknessString = ', '.join('%i%s'%(w,ext[i]) \ |
|---|
| | 1092 | for i,w in enumerate(worthDarkness) if w != 0) |
|---|
| | 1093 | worthMonster = (tplayer.monsterPlatinum,tplayer.monsterGold, \ |
|---|
| | 1094 | tplayer.monsterSilver,tplayer.monsterCopper,tplayer.monsterTin) |
|---|
| | 1095 | monsterString = ', '.join('%i%s'%(w,ext[i]) \ |
|---|
| | 1096 | for i,w in enumerate(worthMonster) if w != 0) |
|---|
| | 1097 | |
|---|
| | 1098 | # And print the result to the immortal. |
|---|
| | 1099 | mob.player.sendGameText(RPG_MSG_GAME_WHITE, \ |
|---|
| | 1100 | "%s's wealth:\\n Light: %s\\n Darkness: %s\\n Monster: %s\\n"% \ |
|---|
| | 1101 | (mob.target.name,lightString,darknessString,monsterString)) |
|---|
| | 1102 | |
|---|
| | 1103 | |
|---|
| | 1104 | def CmdSetWealth(mob, args): |
|---|
| | 1105 | # Check if there is a target available. |
|---|
| | 1106 | if not mob.target: |
|---|
| | 1107 | mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ |
|---|
| | 1108 | "This command requires a target.\\n") |
|---|
| | 1109 | return |
|---|
| | 1110 | |
|---|
| | 1111 | # Check if the two needed arguments are present. |
|---|
| | 1112 | if len(args) != 2: |
|---|
| | 1113 | mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ |
|---|
| | 1114 | "Number of supplied arguments incorrect.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") |
|---|
| | 1115 | return |
|---|
| | 1116 | |
|---|
| | 1117 | # Extract the desired amount of money to set the targets wealth to. |
|---|
| | 1118 | try: |
|---|
| | 1119 | tp,cp,sp,gp,pp = CollapseMoney(int(args[1])) |
|---|
| | 1120 | except ValueError: |
|---|
| | 1121 | mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ |
|---|
| | 1122 | "Can't extract amount of tin argument.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") |
|---|
| | 1123 | return |
|---|
| | 1124 | |
|---|
| | 1125 | # Get a handle to the targets player. |
|---|
| | 1126 | tplayer = mob.target.player |
|---|
| | 1127 | |
|---|
| | 1128 | # Extract the realm and set wealth to the new value. |
|---|
| | 1129 | realmText = args[0].upper() |
|---|
| | 1130 | if realmText == 'LIGHT': |
|---|
| | 1131 | tplayer.lightTin = tp |
|---|
| | 1132 | tplayer.lightCopper = cp |
|---|
| | 1133 | tplayer.lightSilver = sp |
|---|
| | 1134 | tplayer.lightGold = gp |
|---|
| | 1135 | tplayer.lightPlatinum = pp |
|---|
| | 1136 | elif realmText == 'DARKNESS': |
|---|
| | 1137 | tplayer.darknessTin = tp |
|---|
| | 1138 | tplayer.darknessCopper = cp |
|---|
| | 1139 | tplayer.darknessSilver = sp |
|---|
| | 1140 | tplayer.darknessGold = gp |
|---|
| | 1141 | tplayer.darknessPlatinum = pp |
|---|
| | 1142 | elif realmText == 'MONSTER': |
|---|
| | 1143 | tplayer.monsterTin = tp |
|---|
| | 1144 | tplayer.monsterCopper = cp |
|---|
| | 1145 | tplayer.monsterSilver = sp |
|---|
| | 1146 | tplayer.monsterGold = gp |
|---|
| | 1147 | tplayer.monsterPlatinum = pp |
|---|
| | 1148 | else: |
|---|
| | 1149 | mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ |
|---|
| | 1150 | "Can't extract realm argument.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") |
|---|
| | 1151 | return |
|---|
| | 1152 | |
|---|
| | 1153 | # Generate the money string. |
|---|
| | 1154 | ext = ('pp','gp','sp','cp','tp') |
|---|
| | 1155 | worth = (pp,gp,sp,cp,tp) |
|---|
| | 1156 | moneyString = ', '.join('%i%s'%(w,ext[i]) for i,w in enumerate(worth) if w != 0) |
|---|
| | 1157 | |
|---|
| | 1158 | # Print result to the immortal and log. |
|---|
| | 1159 | mob.player.sendGameText(RPG_MSG_GAME_WHITE, \ |
|---|
| | 1160 | "%s's wealth in the %s realm has been set to: %s.\\nPlease inform the player once all adjustments have taken place.\\n"%(mob.target.name,args[0],moneyString)) |
|---|
| | 1161 | print "Immortal %s has set %s's wealth in the %s realm to %s."% \ |
|---|
| | 1162 | (mob.player.publicName,tplayer.fantasyName,args[0],moneyString) |
|---|
| | 1163 | |
|---|
| | 1164 | # Informing the player about the change is left up to the immortal. |
|---|
| | 1165 | # Maybe several changes have to be made before the player should be informed. |
|---|
| | 1166 | |
|---|
| | 1167 | |
|---|