PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/arena/payout/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd / gnofly / arena / payout
Files
6 (gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/arena/payout/v0
gno
0.9

Files (6)

  • gnomod.tomltoml
  • battleroyale.gnogno
  • deathmatch.gnogno
  • doc.gnogno
  • parse.gnogno
  • payout.gnogno
battleroyale.gnogno
1package payout23// BattleRoyale is the winner-takes-all rule. The pot is every stake; the fee is4// taken from it, and the rest goes to:5//6//   - the last player in;7//   - when the clock ran out with several in, the one of them with the most8//     kills, and players still in with as many kills share it equally;9//   - and when everyone is out, the player who went out last.10//11// It is won by staying in the air, not by scoring: the kill target is12// ignored, and the arena realm refuses a battle-royale spec that has one.13//14// What the split leaves over goes to the fee.15type BattleRoyale struct{}1617var _ Rule = BattleRoyale{}1819func (BattleRoyale) Mode() string { return ModeBattleRoyale }2021func (BattleRoyale) Settle(g Game, players []address, deaths []Death) (Result, error) {22	t, err := check(g, players, deaths)23	if err != nil {24		return Result{}, err25	}26	// The most kills among the players still in.27	best := int64(-1)28	for i := range players {29		if !t.out(i, g.Lives) && t.kills[i] > best {30			best = t.kills[i]31		}32	}33	won := make([]bool, len(players))34	winners := int64(0)35	for i := range players {36		if !t.out(i, g.Lives) && t.kills[i] == best {37			won[i] = true38			winners++39		}40	}41	if winners == 0 {42		won[t.lastOut] = true43		winners = 144	}4546	pot := g.Stake * int64(len(players))47	share := afterFee(pot, g.FeeBps) / winners48	res := Result{Fee: pot - share*winners}49	if share == 0 {50		return res, nil // a pot too small to split: nobody is paid51	}52	for i, p := range players {53		if won[i] {54			res.Payouts = append(res.Payouts, Payout{Address: p, Amount: share})55		}56	}57	return res, nil58}59

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.