codingame_tools.client.common.protocol.clash_of_code¶
clash_of_code
¶
JSON-serializable dataclasses for the ClashOfCode service's getClashRankByCodinGamerId and findClashByHandle Codingame API methods.
CgSolutionLanguage
module-attribute
¶
CgSolutionLanguage = str
The programming language used for the reference solution, e.g. "Python3", "Java", "C++", etc.
Code submitted/played (TestSession/play, TestSession/submit, contribution
updateContribution/createContribution) runs server-side in a sandbox with a specific
version and, for some languages, specific bundled libraries--relevant to know when writing a
solution that assumes a particular language feature or library is available. Confirmed:
- Python3: 3.11.5, with NumPy, pandas, and SciPy available.
Other languages' exact versions/bundled libraries aren't catalogued here yet--see https://www.codingame.com/playgrounds/40701/help-center/languages-versions (a client-rendered page; fetching it programmatically only returns the loading shell, not the real content, so this couldn't be filled in automatically--add entries here as they're confirmed for other languages actually in use).
File-extension mapping for a CgSolutionLanguage lives in codingame_tools.language
(get_language(cg_id).extension / get_language_by_extension(ext)), not here--this module is
wire-protocol schema only.
CgClashMode
module-attribute
¶
CgClashMode = str
A Clash of Code game mode, e.g. "FASTEST", "SHORTEST", "REVERSE".
CgClashType
module-attribute
¶
CgClashType = str
The kind of clash, e.g. "FEATURED_EVENT". Only one value observed so far, so other kinds
(e.g. an ad-hoc private/public clash created directly by codingamers) are unconfirmed, and
may have a different set of fields--e.g. CgClash.featured_event_handle is presumably only
populated for clash_type == "FEATURED_EVENT".
CgClashPlayerStatus
module-attribute
¶
CgClashPlayerStatus = str
A clash player's status, e.g. "STANDARD". Only one value observed so far.
CgTestSessionStatus
module-attribute
¶
CgTestSessionStatus = str
The status of a clash player's test session, e.g. "COMPLETED". Only one value observed so far (from a finished clash); an in-progress or not-yet-started clash's players likely use a different value pending further examples.
CgClashRank
dataclass
¶
CgClashRank(rank, total_players, extra_data=dict())
CgClashPlayer
dataclass
¶
CgClashPlayer(codingamer_handle, codingamer_id, codingamer_nickname, duration, language_id, position, rank, score, solution_shared, status, submission_id, test_session_handle, test_session_status, extra_data=dict(), codingamer_avatar_id=None)
Bases: JSONWizardX
A single player's participation/result in a clash, as embedded in CgClash.players.
Only a single finished clash (6 players, all status == "STANDARD") and a single
not-yet-started clash (no players) have been observed so far, so optionality of fields
beyond codingamer_avatar_id is unconfirmed--e.g. a player who left mid-clash or never
submitted may be missing score/rank/duration.
duration
instance-attribute
¶
duration
Milliseconds the player took to reach their final submission.
position
instance-attribute
¶
position
Unclear precise semantics--observed distinct from rank (e.g. position 2 ranked 1st).
Possibly join order into the clash.
solution_shared
instance-attribute
¶
solution_shared
Whether the player chose to publicly share their solution after the clash.
test_session_handle
instance-attribute
¶
test_session_handle
Opaque handle for the player's test session against this clash.
test_session_status
instance-attribute
¶
test_session_status
Status of the player's test session; see CgTestSessionStatus.
codingamer_avatar_id
class-attribute
instance-attribute
¶
codingamer_avatar_id = None
The binary image ID of the player's avatar image. Not always present--observed absent for at least half the players in one finished clash.
CgClash
dataclass
¶
CgClash(clash_duration_type_id, finished, mode, modes, ms_before_end, ms_before_start, nb_players_min, players, programming_languages, public_handle, started, _start_timestamp=Alias('startTimestamp'), clash_type=Alias('type'), extra_data=dict(), featured_event_handle=None)
Bases: JSONWizardX
A single Clash of Code session, as returned by findClashByHandle. handle (the argument
to this endpoint) must be a clash-instance handle (e.g. CgFeaturedEvent's own handle
does NOT work here--confirmed via 422--but a per-slot CgClashSlot.clash_handle from
FeaturedEvent/findClashSlots does).
clash_duration_type_id
instance-attribute
¶
clash_duration_type_id
Duration category for the clash, e.g. "SHORT".
modes
instance-attribute
¶
modes
All game modes in effect for this clash. Only ever observed containing the same single
value as mode, so multi-mode clashes are unconfirmed.
ms_before_end
instance-attribute
¶
ms_before_end
Milliseconds remaining before the clash ends. Negative if it has already ended.
ms_before_start
instance-attribute
¶
ms_before_start
Milliseconds remaining before the clash starts. Negative if it has already started.
nb_players_min
instance-attribute
¶
nb_players_min
Minimum number of players required for the clash to proceed.
players
instance-attribute
¶
players
Players who have joined the clash. Empty for a clash that hasn't started yet.
programming_languages
instance-attribute
¶
programming_languages
Programming languages available for this clash.
public_handle
instance-attribute
¶
public_handle
The clash's opaque public handle, matching the handle argument passed in.
clash_type
class-attribute
instance-attribute
¶
clash_type = Alias('type')
The kind of clash; see CgClashType.
featured_event_handle
class-attribute
instance-attribute
¶
featured_event_handle = None
The CgFeaturedEvent.handle of the featured event this clash belongs to, if any. See
CgClashType for the (unconfirmed) relationship to clash_type.
start_timestamp
property
writable
¶
start_timestamp
See the field docstring for _start_timestamp. Always UTC.