Verse Library verse

18 Complete Code

Defines classes and maps to track player finish order and round state persistently.

extracted-snippets/documentation/en-us/uefn/custom-round-logic-in-verse/18-complete-code.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/custom-round-logic-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/custom-round-logic-in-verse.md
# Section:    Complete Code
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# A persistable map that maps each player to
# what order they finished the previous round.
var CircuitInfo<public>:weak_map(player, player_circuit_info) = map{}

# Maps the current session to its associated round info.
var RoundInfo:weak_map(session, round_info) = map{}

round_info := class:
    CurrentRound:int = -1

# Tracks the number of and in what order a player finished the previous round.
player_circuit_info<public> := class<final><persistable>:
    Version:int = 0
    LastRoundFinishOrder:int = -1
    LastCompletedRound<public>:int = -1

# Creates a new player_circuit_info from the given older player_circuit_info.
MakePlayerCircuitInfo<constructor>(OldPlayerCircuitInfo:player_circuit_info)<transacts> := player_circuit_info:
    Version := OldPlayerCircuitInfo.Version
    LastRoundFinishOrder := OldPlayerCircuitInfo.LastRoundFinishOrder
    LastCompletedRound := OldPlayerCircuitInfo.LastCompletedRound

# Returns true if this is the first round of the game.
IsFirstRound<public>(RoundToCheck:int)<decides><transacts>:void=

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in