Table of Contents

Struct PlotOwner

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Who owns a plot: a character, a guild, or nobody.

public readonly struct PlotOwner : IEquatable<PlotOwner>
Implements
Inherited Members

Remarks

A plot row stores ownership as two columns, an owning character and an owning guild, and exactly one of them may be set. Nothing in the schema enforces that — the codebase has no check constraints, and neither column can carry a foreign key because both use zero to mean "none" — so the invariant is held here instead, in a type that cannot represent a plot owned by a character and a guild at once.

Rows are read back through TryFromColumns(long, long, out PlotOwner) rather than a constructor, so a row that does somehow hold both is refused at the boundary instead of being resolved by whichever column the reader happened to check first. Two readers guessing differently about the same plot is how one owner ends up able to build on it and another ends up able to sell it.

Fields

None

An unclaimed plot.

public static readonly PlotOwner None

Field Value

PlotOwner

Properties

CharacterID

The owning character, or zero when the plot is unowned or guild-owned.

public long CharacterID { get; }

Property Value

long

Remarks

Written straight into the plot row's owner column, which is why it reports zero rather than the guild's identifier for a guild-owned plot.

GuildID

The owning guild, or zero when the plot is unowned or character-owned.

public long GuildID { get; }

Property Value

long

ID

The owner's identifier, interpreted according to Type. Zero when unowned.

public long ID { get; }

Property Value

long

IsOwned

True when somebody owns the plot.

public bool IsOwned { get; }

Property Value

bool

Type

What kind of holder owns the plot.

public PlotOwnerType Type { get; }

Property Value

PlotOwnerType

Methods

Equals(PlotOwner)

public bool Equals(PlotOwner other)

Parameters

other PlotOwner

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

ForCharacter(long)

Ownership by an individual character.

public static PlotOwner ForCharacter(long characterID)

Parameters

characterID long

The owning character. Must be greater than zero.

Returns

PlotOwner

Remarks

Throws rather than returning None, because an identifier of zero here is a caller that has lost track of who it is acting for. Quietly folding that into "unowned" would answer a claim by releasing the plot to everyone.

Exceptions

ArgumentOutOfRangeException

Thrown when characterID is not greater than zero.

ForGuild(long)

Ownership by a guild.

public static PlotOwner ForGuild(long guildID)

Parameters

guildID long

The owning guild. Must be greater than zero.

Returns

PlotOwner

Exceptions

ArgumentOutOfRangeException

Thrown when guildID is not greater than zero.

GetHashCode()

public override int GetHashCode()

Returns

int

IsAllowedBy(HousingOwnershipMode)

True when this kind of ownership is permitted by the server's housing configuration.

public bool IsAllowedBy(HousingOwnershipMode mode)

Parameters

mode HousingOwnershipMode

Returns

bool

Remarks

The gate that HousingOwnershipMode exists to provide, asked in the one place that knows what kind of owner is being proposed. None is permitted under every mode including Neither: releasing a plot has to keep working on a server that has since turned housing off, or plots claimed while it was on could never be given back.

ToString()

public override string ToString()

Returns

string

TryFromColumns(long, long, out PlotOwner)

Reads ownership back from a plot row's two owner columns.

public static bool TryFromColumns(long ownerCharacterID, long ownerGuildID, out PlotOwner owner)

Parameters

ownerCharacterID long

The row's owning character, zero for none.

ownerGuildID long

The row's owning guild, zero for none.

owner PlotOwner

The ownership the columns describe, or None on failure.

Returns

bool

False when the columns contradict each other or hold a negative identifier.

Remarks

Both columns set is not a state any writer here produces, so encountering it means the row was written by something else or corrupted. Refusing it keeps that damage contained to the one plot rather than letting each reader invent its own answer.

Operators

operator ==(PlotOwner, PlotOwner)

public static bool operator ==(PlotOwner left, PlotOwner right)

Parameters

left PlotOwner
right PlotOwner

Returns

bool

operator !=(PlotOwner, PlotOwner)

public static bool operator !=(PlotOwner left, PlotOwner right)

Parameters

left PlotOwner
right PlotOwner

Returns

bool