Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AttackDefTeam #69

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add AttackDefTeam #69

wants to merge 3 commits into from

Conversation

tnmkr
Copy link

@tnmkr tnmkr commented Feb 17, 2025

Added new model with two new routes under '/ctf/round2/list' and '/team/round2/powerups' to list a team's ctfs and used powerups respectively.

Also added test rows in admin init for new models.

Fixes: #52

@tnmkr tnmkr marked this pull request as ready for review February 18, 2025 13:28
Comment on lines +86 to +93
@router.get("/round2/list")
async def ctf_list(jwt: RequireJwt):
team_id = jwt["team_id"]
attack_def_team = await AttackDefTeam.get(team_id=team_id)
if (attack_def_team is None):
return {"msg_code": config.msg_codes["attack_def_team_not_found"]}
problems = await Problem_Pydantic.from_queryset(Problem.filter(attackdefproblem__attack_def_team__id=attack_def_team.id))
return await calculate_problem_points(problems, team_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not fetch the CTFs for all teams. It only fetches the CTFs assigned to the team calling this endpoint.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate path /round2/list_all to return all problems. From this endpoint, we do not calculate actual points based on hints used.

Is this what you wanted?

Comment on lines 82 to 98
powerups={
PowerUpType.UPGRADE: {
"cost": 100,
},
PowerUpType.SHIELD: {
"duration": timedelta(seconds=10),
"cost": 200,
},
PowerUpType.POINT_SIPHON: {
"duration": timedelta(seconds=15),
"cost": 150,
},
PowerUpType.SABOTAGE: {
"duration": timedelta(seconds=5),
"cost": 500,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to a dataclass and have add field count as max number of uses. Validate to ensure maximum uses is not exceeded when consuming the powerup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted to dataclass, however I did not write logic for using power-ups yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attack/Defence: Teams
2 participants