@@ -113,6 +113,7 @@ type info = {
113
113
rate_war : bool ;
114
114
rates : [`Normal | `Double | `Half ];
115
115
cargo_revenue : int Goods.Map .t ; (* revenue for each cargo type at this station *)
116
+ holds_priority_shipment : bool ;
116
117
} [@@ deriving yojson ]
117
118
118
119
let has_demand_for v good = Goods.Set. mem good v.demand
@@ -158,6 +159,14 @@ let with_info v f = match v.info with
158
159
| Some x -> Some (f x)
159
160
| _ -> None
160
161
162
+ let update_with_info v f = match v.info with
163
+ (* None = don't update *)
164
+ | Some x -> begin match f x with
165
+ | Some _ as info -> {v with info}
166
+ | None -> v
167
+ end
168
+ | _ -> v
169
+
161
170
let get_age v year = year - v.year
162
171
163
172
let color_of_signal = function
@@ -274,6 +283,7 @@ let make ~x ~y ~year ~city_xy ~city_name ~suffix ~kind ~player ~first =
274
283
rate_war= false ;
275
284
rates= `Normal ;
276
285
cargo_revenue= Goods.Map. empty;
286
+ holds_priority_shipment= false ;
277
287
} |> Option. some
278
288
in
279
289
let signals = default_signals in
@@ -438,4 +448,17 @@ let color_of_rates v = match v.info with
438
448
end
439
449
| _ -> failwith " Shouldn't get here"
440
450
451
+ let holds_priority_shipment v =
452
+ Option. map_or
453
+ ~default: false
454
+ (fun x -> x.holds_priority_shipment)
455
+ v.info
456
+
457
+ let set_priority_shipment v x =
458
+ update_with_info v
459
+ (fun info ->
460
+ if Bool. equal info.holds_priority_shipment x then
461
+ None
462
+ else
463
+ Some {info with holds_priority_shipment = x})
441
464
0 commit comments