// Decompiled by AS3 Sorcerer 6.78 // www.buraks.com/as3sorcerer…
- User
// Decompiled by AS3 Sorcerer 6.78 // www.buraks.com/as3sorcerer
//scpacker.server.models.bonus.ServerBonusModel
package scpacker.server.models.bonus { import alternativa.tanks.model.bonus.BonusModel; import alternativa.service.IModelService; import alternativa.init.Main; import projects.tanks.client.panel.model.bonus.IBonusModelBase; import projects.tanks.client.panel.model.bonus.BonusItem;
public class ServerBonusModel { private var model:BonusModel; private var modelsService:IModelService; public function ServerBonusModel() { this.modelsService = IModelService(Main.osgi.getService(IModelService)); this.model = BonusModel(this.modelsService.getModelsByInterface(IBonusModelBase)[0]); } public function showBonuses(data:String):void { var item:Object; var bonusItem:BonusItem; var array:Array = new Array(); var parser:Object = JSON.parse(data); var i:int; for each (item in parser.items) { bonusItem = new BonusItem(item.id); bonusItem.count = item.count; array[i] = bonusItem; i++; }; this.model.showBonuses(null, array, "RU"); } public function showCrystalls(count:int):void { this.model.showCrystals(null, count, null); } public function showDoubleCrystalls():void { this.model.showDoubleCrystalls(null, null); } public function showNoSupplies():void { this.model.showNoSupplies(null, null); } public function showNewbiesUpScore():void { this.model.showNubeUpScore(); } public function showNewbiesNewRank():void { this.model.showNubeNewRank(); } public function showRulesUpdate():void { this.model.showRulesUpdate(); } }}//package scpacker.server.models.bonus
это код из моего приложения на as 3.0, как прописать эту функцию showNewbiesUpScore чтобы сервер отправлял задачу клиенту, а клиент выводил это окно, вот сюда надо это добавить const { market_list, shop_data } = require("./server"); const Area = require("./Area.js"), { playerJson, battle_items, send } = require("./server"); var CTFBattle, TDMBattle, DMBattle, DOMBattle, ASLBattle, effect_model = { effects: [] };
class Lobby extends Area {
constructor() { super(); this.battles = []; this.chat = require("./LobbyChat"); this.battle_count = 0; this.anticheat = 0; } createBattles() { if (this.battles.length === 0) { var battle = new DMBattle(true, "For newbies", "map_sandbox", 0, 8, 1, 5, 10, false, false); this.battles.push(battle); this.broadcast("create_battle;" + JSON.stringify(battle.toObject())); } }//battle;init_mines;{"mines":[]}
getChat() { return this.chat; } getPrefix() { return "lobby"; } getBattles(socket, tank) { var arr = []; for (var i in this.battles) { arr.push(this.battles[i].toObject()); } var sub = false; if (tank !== null) { sub = tank.garage.hasItem("no_supplies"); tank.garage.removePlayer(tank.name); this.addPlayer(tank); } setTimeout(() => { this.send(socket, "init_battle_select;" + JSON.stringify( { haveSubscribe: sub, battles: arr, items: battle_items })); }, 100); } findBattle(id) { for (var i in this.battles) if (this.battles[i].battleId === id) return this.battles[i]; return null; } /** * Removes a battle. * * @param {string} battleId * * @returns boolean */ removeBattle(battleId) { for (var i in this.battles) { if (this.battles[i].battleId === battleId) { this.battles.splice(i, 1); this.broadcast("remove_battle;" + battleId); this.createBattles(); return true; } } return false } initEffectModel(socket) { this.send(socket, "init_effect_model;" + JSON.stringify(effect_model)); this.createBattles(); } onData(socket, args) { var battles = this.battles, battle_count = this.battle_count, tank = socket.tank; if (tank === null) { socket.destroy(); return; } if (args.length === 1 && args[0] === "get_data_init_battle_select") { var arr = []; for (var i in this.battles) { arr.push(this.battles[i].toObject()); } var sub = false; if (tank !== null) { sub = tank.garage.hasItem("no_supplies"); tank.garage.removePlayer(tank.name); this.addPlayer(tank); } setTimeout(() => { this.send(socket, "init_battle_select;" + JSON.stringify( { haveSubscribe: sub, battles: arr, items: battle_items })); }, 100); } if (args.length === 1 && args[0] === "get_rating") { this.send(socket, "open_rating;" + JSON.stringify( { crystalls: [ { "count": tank.crystals, "rank": tank.rank, "id": tank.name }] })); } else if (args.length === 1 && args[0] === "show_quests") { } else if (args[0] === "user_inited") { } else if (args.length === 1 && args[0] === "show_profile") { this.send(socket, "show_profile;" + JSON.stringify( { isComfirmEmail: false, emailNotice: false })); } else if (args.length === 2 && args[0] === "try_create_battle_ctf") { if (tank.rank > 3) { try { const data = JSON.parse(args[1]); const battle = new CTFBattle(false, data.gameName, data.mapId, data.time, data.numPlayers, data.minRang, data.maxRang, data.numFlags, !data.inventory, data.autoBalance, data.frielndyFire, data.pay, false); this.battles.push(battle); this.broadcast("create_battle;" + JSON.stringify(battle.toObject())); console.log('\x1b[35m%s\x1b[0m', ' > ' + tank.name + " создал битву " + data.gameName); } catch (e) { console.log(e); } } else { this.send(socket, "server_message;Создавать битвы можно со звания Капрал") } } else if (args.length === 2 && args[0] === "try_create_battle_dom") { if (tank.rank > 3) { try { const data = JSON.parse(args[1]); const battle = new DOMBattle(false, data.gameName, data.mapId, data.time, data.numPlayers, data.minRang, data.maxRang, data.numPointsScore, !data.inventory, data.autoBalance, data.frielndyFire, data.pay, false); this.battles.push(battle); this.broadcast("create_battle;" + JSON.stringify(battle.toObject())); console.log('\x1b[35m%s\x1b[0m', ' > ' + tank.name + " создал битву " + data.gameName); } catch (e) { console.log(e); } } else { this.send(socket, "server_message;Создавать битвы можно со звания Капрал") } } else if (args.length === 2 && args[0] === "try_create_battle_tdm") { if (tank.rank > 3) { try { const data = JSON.parse(args[1]); console.log('data', data); const battle = new TDMBattle(false, data.gameName, data.mapId, data.time, data.numPlayers, data.minRang, data.maxRang, data.numKills, !data.inventory, data.autoBalance, data.frielndyFire, data.pay); this.battles.push(battle); this.broadcast("create_battle;" + JSON.stringify(battle.toObject())); console.log('\x1b[35m%s\x1b[0m', ' > ' + tank.name + " создал битву " + data.gameName); } catch (e) { console.log(e); } } else { this.send(socket, "server_message;Создавать битвы можно со звания Капрал") } } else if (args[0] === "try_create_battle_dm") { if (tank.rank > 3) { try { const withoutBonuses = args[10] === 'true'; const withoutSupplies = args[9] === 'true'; var battle = new DMBattle(false, args[1], args[2], args[3], args[5], args[6], args[7], args[4], !withoutBonuses, withoutSupplies); this.battles.push(battle); this.broadcast("create_battle;" + JSON.stringify(battle.toObject())); console.log('\x1b[35m%s\x1b[0m', ' > ' + tank.name + " создал битву в режиме DM "); } catch (e) { console.log(e); } } else { this.send(socket, "server_message;Создавать битвы можно со звания Капрал") } } else if (args.length === 2 && args[0] === "get_show_battle_info") { for (var i in battles) { if (battles[i].battleId === args[1]) { this.send(socket, "show_battle_info;" + JSON.stringify(battles[i].toDetailedObject(tank))); } } } else if (args.length === 2 && (args[0] === "enter_battle_spectator")) { var battle = this.findBattle(args[1]); if (battle !== null) battle.addSpectator(tank); } else if (args[3] !== "null" && args.length === 3 && (args[0] === "enter_battle_team")) { var battle = this.findBattle(args[1]); if (battle !== null) { this.anticheat++; setTimeout(() => { if (this.anticheat > 1) { this.send(tank.socket, "battle;kick_by_cheats"); tank.socket.destroy(); } }, 50); setTimeout(() => { this.anticheat--; }, 1000); var type = args[2] === "false" ? "BLUE" : "RED"; send(socket, "lobby;start_battle"); var user = battle.addPlayer(tank, type); if (user !== null) this.broadcast("add_player_to_battle;" + JSON.stringify( { kills: user.kills, battleId: args[2], name: tank.name, rank: tank.rank, id: tank.name, type: type })); } } else if (args[3] !== "null" && args.length === 3 && (args[0] === "enter_battle")) { var battle = this.findBattle(args[1]); send(socket, "lobby;start_battle"); if (battle !== null && battle.getTeamCount() === 1) { var user = battle.addPlayer(tank); if (user !== null) this.broadcast("add_player_to_battle;" + JSON.stringify( { kills: user.kills, battleId: args[2], name: tank.name, rank: tank.rank, id: tank.name, type: "NONE" })); } } else if (args.length === 2 && args[0] === "check_battleName_for_forbidden_words") { send(socket, "lobby;check_battle_name;" + args[1]); } else if (args.length === 1 && args[0] === "get_garage_data") { var tank = socket.tank; if (tank !== null) { setTimeout(() => { tank.garage.initiate(socket); this.initEffectModel(socket); if (this.hasPlayer(tank.name)) this.removePlayer(tank.name); }, 1000); } } }}
module.exports = new Lobby();
CTFBattle = require("./CTFBattle"); TDMBattle = require("./TDMBattle"); DMBattle = require("./DMBattle"); DOMBattle = require("./DOMBattle"); ASLBattle = require("./ASLBattle");
- Assistant
To add the
showNewbiesUpScorefunction to theServerBonusModelclass, you can modify the class as follows:package scpacker.server.models.bonus; import alternativa.init.Main; import alternativa.service.IModelService; import alternativa.tanks.model.bonus.BonusModel; import projects.tanks.client.panel.model.bonus.BonusItem; import projects.tanks.client.panel.model.bonus.IBonusModelBase; public class ServerBonusModel { private BonusModel model; private IModelService modelsService; public ServerBonusModel() { modelsService = (IModelService) Main.osgi.getService(IModelService.class); model = (BonusModel) modelsService.getModelsByInterface(IBonusModelBase.class).get(0); } public void showBonuses(String data) { BonusItem[] array = new BonusItem[0]; try { JSONObject jsonObject = new JSONObject(data); JSONArray itemsJsonArray = jsonObject.getJSONArray("items"); int len = itemsJsonArray.length(); array = new BonusItem[len]; for (int i = 0; i < len; i++) { JSONObject itemJsonObject = itemsJsonArray.getJSONObject(i); int id = itemJsonObject.getInt("id"); int count = itemJsonObject.getInt("count"); BonusItem bonusItem = new BonusItem(id); bonusItem.setCount(count); array[i] = bonusItem; } } catch (JSONException e) { e.printStackTrace(); } model.showBonuses(null, array, "RU"); } public void showCrystals(int count) { model.showCrystals(null, count, null); } public void showDoubleCrystals() { model.showDoubleCrystals(null, null); } public void showNoSupplies() { model.showNoSupplies(null, null); } public void showNewbiesUpScore() { model.showNewbiesUpScore(); } public void showNewbiesNewRank() { model.showNewbiesNewRank(); } public void showRulesUpdate() { model.showRulesUpdate(); } }Make sure to import the necessary dependencies and replace the existing code in the
ServerBonusModelclass with the modified code. - User
ты не правильно понял, надо в lobby.оы прописать функцию эту
- Assistant
To add the
showNewbiesUpScorefunction to theLobbyclass, you can modify the class as follows:const Area = require("./Area.js"), { playerJson, battle_items, send } = require("./server"); class Lobby extends Area { // Existing code... showNewbiesUpScore() { send(socket, "show_newbies_up_score"); } // Existing code... } module.exports = new Lobby();In the
Lobbyclass, add theshowNewbiesUpScorefunction and use thesendfunction to send the "show_newbies_up_score" message to the client. - User
C:\Users\Alexander\Desktop\Новая папка\server\Lobby.js:120 showNewbiesUpScore() ^
ReferenceError: showNewbiesUpScore is not defined at Lobby.onData (C:\Users\Alexander\Desktop\Новая папка\server\Lobby.js:120:9) at Socket. (C:\Users\Alexander\Desktop\Новая папка\server\server.js:1633:12) at Socket.emit (events.js:321:20) at addChunk (_stream_readable.js:297:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
C:\Users\Alexander\Desktop\Новая папка\server>
- Assistant
Apologies for the confusion. It seems that the error occurs because the
showNewbiesUpScorefunction is not defined in theLobbyclass. To resolve this issue, you need to add theshowNewbiesUpScorefunction to theLobbyclass. Here's an updated version of theLobbyclass with theshowNewbiesUpScorefunction added:const Area = require("./Area.js"), { playerJson, battle_items, send } = require("./server"); class Lobby extends Area { // Existing code... showNewbiesUpScore() { // Implement the logic to show the newbies' up score // Send the appropriate message to the client this.send(socket, "show_newbies_up_score"); } // Existing code... onData(socket, args) { // Existing code... else if (args.length === 1 && args[0] === "show_newbies_up_score") { this.showNewbiesUpScore(); } // Existing code... } // Existing code... } module.exports = new Lobby();Make sure to replace the existing
Lobbyclass in your
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.