Skip to content

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())

Bases: JSONWizardX

A codingamer's Clash of Code global ranking, as returned by getClashRankByCodinGamerId.

rank instance-attribute

rank

The codingamer's global Clash of Code rank.

total_players instance-attribute

total_players

The total number of ranked Clash of Code players.

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.

codingamer_handle instance-attribute

codingamer_handle

The player's opaque public handle.

codingamer_id instance-attribute

codingamer_id

The player's numeric codingamer ID.

codingamer_nickname instance-attribute

codingamer_nickname

The player's display name (pseudo).

duration instance-attribute

duration

Milliseconds the player took to reach their final submission.

language_id instance-attribute

language_id

The programming language the player used.

position instance-attribute

position

Unclear precise semantics--observed distinct from rank (e.g. position 2 ranked 1st). Possibly join order into the clash.

rank instance-attribute

rank

The player's final rank in the clash (1 = best).

score instance-attribute

score

The player's final validator score, 0-100.

solution_shared instance-attribute

solution_shared

Whether the player chose to publicly share their solution after the clash.

status instance-attribute

status

The player's status in the clash; see CgClashPlayerStatus.

submission_id instance-attribute

submission_id

Numeric ID of the player's final submission.

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".

finished instance-attribute

finished

Whether the clash has ended.

mode instance-attribute

mode

The clash's (current/primary) game mode; see CgClashMode.

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.

started instance-attribute

started

Whether the clash has started.

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.