maps-service/validation/src/maptest.rs

86 lines
2.5 KiB
Rust
Raw Normal View History

2024-11-26 04:28:50 +00:00
use std::collections::HashSet;
2024-11-26 01:30:55 +00:00
2024-11-26 04:28:50 +00:00
type GameID=u32;
type StyleID=u32;
type TimeID=u64;
// the status is supposed to walk up the phases ascending
2024-11-26 01:30:55 +00:00
enum Status{
2024-11-26 04:28:50 +00:00
// Phase 3: Retired
Published,// pipeline is complete, map was published
Rejected,// map council will not request changes, submit a new map
// Phase 2: Staging
Publishing,// Admin clicked the publish button, publishing is in progress and should only take a second
Validated,// Validator validated the map, expose a "Publish" button to Admins
2024-11-26 05:18:01 +00:00
Validating,// Validator has been invoked
Accepted,// Map failed validation but is still accepted
2024-11-26 04:28:50 +00:00
// Phase 1: Maptest
ChangesRequested,// map council requests changes
Submitted,// Submitted by owner for review by map council, expose "Accept" / "Reject" / "ChangesRequested" to reviewers
UnderConstruction,// default state upon pipeline creation
2024-11-26 01:30:55 +00:00
}
2024-11-26 05:18:01 +00:00
/* Valid state transitions and their required permission roles
Submitter:
UnderConstruction -> Submitted
ChangesRequested -> Submitted
Reviewer:
Submitted -> Validating
Submitted -> Rejected
Accepted -> ChangesRequested
Validated -> ChangesRequested
Accepted -> Validating // re-validate
Validator:
Validating -> Validated
Publishing -> Published
Admin:
Validated -> Publishing
*/
2024-11-26 01:30:55 +00:00
2024-11-26 05:33:56 +00:00
enum SubmissionType{
// changes an existing map on publish
Fix{
2024-11-26 04:28:50 +00:00
//main game target asset id
asset_id:u64,
// How is this data entered? It should be suggested by map maker and finalized by time deleter
//affected styles to be wiped upon publish
delete_styles:Option<HashSet<(GameID,StyleID)>>,
//affected times to be individually removed
delete_times:Option<HashSet<TimeID>>,
2024-11-26 01:30:55 +00:00
},
2024-11-26 05:33:56 +00:00
// creates a new map on publish
New{
2024-11-26 04:28:50 +00:00
games:HashSet<GameID>,
2024-11-26 01:30:55 +00:00
creator:String,
display_name:String,
},
}
2024-11-26 05:33:56 +00:00
struct Submission{
// IMMUTABLE FIELDS
2024-11-26 01:30:55 +00:00
//maptest database entry id
id:u64,
date:u64,
// int64 UserID who created the submission
2024-11-26 04:28:50 +00:00
// this user is allowed to change any data in the maptest phase, except for mapfix target map id
2024-11-26 05:18:01 +00:00
submitter:u64,
2024-11-26 05:33:56 +00:00
// MUTABLE FIELDS (depending on roles and status)
2024-11-26 01:30:55 +00:00
model_id:u64,// asset id of the most recently submitted model
2024-11-26 04:28:50 +00:00
model_version:u64,// snapshot of the model to prevent tampering
is_completed:bool,// has this asset version been completed by any player
2024-11-26 05:33:56 +00:00
submission_type:SubmissionType,
2024-11-26 01:30:55 +00:00
status:Status,
}
2024-11-26 05:33:56 +00:00
/*
Mutability conditions:
model_id:
Submitter - Phase 1
model_version:
Submitter - Phase 1
is_completed:
Maptest place - no status restriction
maptest_type:
highly conditional
status:
highly conditional
*/