Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: remove artefacts from Worksheet 1 (#1775)
Browse files Browse the repository at this point in the history
* adjust target_num_pickups_per_avatar

* pass tests
  • Loading branch information
cewei8483 authored Jun 6, 2023
1 parent 19a49f6 commit 3e3c44a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion aimmo/game_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# For now it just duplicates a part of aimmo-game-creator/game_manager.py in order to recreate a game server.
import logging
import time

import json
import kubernetes
from kubernetes.client import CoreV1Api
from kubernetes.client.api.custom_objects_api import CustomObjectsApi
Expand Down Expand Up @@ -134,6 +134,12 @@ def recreate_game_server(

game_data = self.delete_game_server(game_id=game_id)
game_data.update(game_data_updates)

if (game_data.get('settings') and isinstance(game_data.get('settings') , str) and game_data.get('worksheet_id')):
setting = json.loads(game_data['settings'])
setting['TARGET_NUM_PICKUPS_PER_AVATAR'] = 0 if game_data['worksheet_id'] == '1' else 1.2
game_data['settings'] = json.dumps(setting)

game_server_name = self.create_game_server_allocation(
game_id=game_id, game_data=game_data
)
Expand Down
18 changes: 18 additions & 0 deletions aimmo/migrations/0032_alter_game_target_num_pickups_per_avatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-06-01 13:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('aimmo', '0031_alter_avatar_auth_token'),
]

operations = [
migrations.AlterField(
model_name='game',
name='target_num_pickups_per_avatar',
field=models.FloatField(default=0),
),
]
3 changes: 2 additions & 1 deletion aimmo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class Game(models.Model):
target_num_cells_per_avatar = models.FloatField(default=16)
target_num_score_locations_per_avatar = models.FloatField(default=0.5)
score_despawn_chance = models.FloatField(default=0.05)
target_num_pickups_per_avatar = models.FloatField(default=1.2)
# Set default pickup num to 0 to remove artefacts from worksheet 1
target_num_pickups_per_avatar = models.FloatField(default=0)
pickup_spawn_chance = models.FloatField(default=0.1)
obstacle_ratio = models.FloatField(default=0.1)
start_height = models.IntegerField(default=31)
Expand Down
4 changes: 2 additions & 2 deletions aimmo/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def expected_game_detail(class_id, worksheet_id):
"era": "1",
"name": "test",
"status": "r",
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 1.2, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 0.0, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"class_id": str(class_id),
"worksheet_id": str(worksheet_id),
}
Expand Down Expand Up @@ -534,7 +534,7 @@ def expected_game_detail(class_id, worksheet_id):
"era": "1",
"name": "test",
"status": "r",
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 1.2, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 0.0, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"class_id": str(class_id),
"worksheet_id": str(worksheet_id),
}
Expand Down

0 comments on commit 3e3c44a

Please sign in to comment.