public class BonusTakeModel { private static final String… · The Chat Archive
Explore public class BonusTakeModel { private static final String SETCRY = "setcry"; private… Save Share Download ▾ Reportpublic class BonusTakeModel {
private static final String SET_CRY = "set_cry";
private static final String ENABLE_EFFECT_COMAND = "enable_effect";
private static final int CRYSTALL_BONUS_COST = 1;
private static final int GOLD_BONUS_COST = 100;
private BattlefieldModel bfModel;
@ServicesInject(
target = DatabaseManagerImpl.class
)
private DatabaseManager database = DatabaseManagerImpl.instance();
// F F : s y n t h e t i c f i e l d p r i v a t e s t a t i c i n t [ ] FF: synthetic field
private static int[] F F : sy n t h e t i c f i e l d p r i v a t es t SWITCH_TABLE battles BonusType;
Show full message · 53 lines Assistant2023-12-08 15:29 UTC Copy response
The BonusTakeModel class is responsible for handling the logic of taking bonuses in a battlefield. Here's a breakdown of the class:
The class has several private constants representing the names and costs of various bonuses.
It has a private field "bfModel" of type BattlefieldModel, which is injected via constructor.
It has a private field "database" of type DatabaseManager, which is also injected via a service injection annotation.
The constructor initializes the "bfModel" field with the provided BattlefieldModel instance.
The "onTakeBonus" method is called when a player takes a bonus. It takes three parameters:
Copy first prompt Copy first response
Details
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language en
Conversation date Dec 8, 2023
Added to archive Nov 16, 2026
ID 01m7h41jggcby0hka8g8b20czdSource & license Imported from WildChat-4.8M (AI2) (source ). Imported records earn no Research Points.
Upstream record: ce612d8d46dfd3fef9d29abcab12cf26
Zhao et al., WildChat: 1M ChatGPT Interaction Logs in the Wild (ICLR 2024). Contains information from WildChat-4.8M, made available under the ODC Attribution License.
License: ODC-BY-1.0
a
t
i
c
in
t
[
]
public BonusTakeModel(BattlefieldModel bfModel) {
this.bfModel = bfModel;
}
public boolean onTakeBonus(Bonus bonus, Vector3 realtimePosTank, BattlefieldPlayerController player) {
switch(S W I T C H T A B L E SWITCH_TABLE S W I T C H T A B L E gtanksb a t t l e s battles ba ttl es bonuses$BonusType()[bonus.type.ordinal()]) {
case 1:
this.bfModel.sendUserLogMessage(player.parentLobby.getLocalUser().getNickname(), "взял золотой ящик");
player.parentLobby.getLocalUser().addCrystall(GOLD_BONUS_COST);
player.send(Type.BATTLE, SET_CRY, String.valueOf(player.parentLobby.getLocalUser().getCrystall()));
this.database.update(player.getUser());
break;
case 2:
player.parentLobby.getLocalUser().addCrystall(CRYSTALL_BONUS_COST);
player.send(Type.BATTLE, SET_CRY, String.valueOf(player.parentLobby.getLocalUser().getCrystall()));
this.database.update(player.getUser());
break;
case 3:
this.activateDrop(new ArmorEffect(), player);
break;
case 4:
this.activateDrop(new HealthEffect(), player);
break;
case 5:
this.activateDrop(new DamageEffect(), player);
break;
case 6:
this.activateDrop(new NitroEffect(), player);
}
code Copy code
return true;
private void activateDrop(Effect effect, BattlefieldPlayerController player) {
if (!player.tank.isUsedEffect(effect.getEffectType())) {
effect.activate(player, false, player.tank.position);
player.battle.sendToAllPlayers(Type.BATTLE, ENABLE_EFFECT_COMAND, player.getUser().getNickname(), String.valueOf(effect.getID()), effect.getEffectType() == EffectType.HEALTH ? String.valueOf(10000) : String.valueOf(40000));
}
"bonus" of type Bonus: The bonus that has been taken.
"realtimePosTank" of type Vector3: The real-time position of the tank.
"player" of type BattlefieldPlayerController: The player who took the bonus.
The method uses a switch statement to perform different actions based on the type of bonus taken. The actions include sending log messages, updating player stats, and activating different effects.
The "activateDrop" method is a private helper method called by "onTakeBonus" to activate a specific effect. It takes two parameters:
"effect" of type Effect: The effect to activate.
"player" of type BattlefieldPlayerController: The player who took the bonus.
The method checks if the effect has already been applied to the player's tank, and if not, activates the effect and sends a command to all players in the battle to enable the effect.
Overall, the BonusTakeModel class handles the logic of taking different types of bonuses in a battlefield, updating player stats, and activating corresponding effects.
Not yet included in a published release.