# worth.ludic - what a buyer pays for a frame: the first frame of each subject and every legend, # on the grade's curve and the lens's worth; sold is sold export function photo_value(photo_st: PhotoState, i: int) -> int { if i < 0 or i >= photo_st.pht_n or photo_st.pht_sold[i] != 0 { return 0 } var v = 0 for sp in 0 .. 32 { if (photo_st.pht_mask[i] & (1 << sp)) == 0 { continue } var first = true for k in 0 .. photo_st.pht_n { if k != i and photo_st.pht_sold[k] != 0 and (photo_st.pht_mask[k] & (1 << sp)) != 0 { first = false } } if first { v += PhotoRules.subject_value(sp) } if (photo_st.pht_legend[i] & (1 << sp)) != 0 { v += PhotoRules.legend_value(sp) } } if v > 0 { v = int(float(v) * (PhotoRules.mult() * photo_grade_mult(photo_st.pht_grade[i]))) } return v } # every frame with a price, sold: the total, and a fact a frame export function photo_sell_all(photo_st: mut PhotoState) -> int { var total = 0 for i in 0 .. photo_st.pht_n { let v = photo_value(photo_st, i) if v > 0 { total += v photo_st.pht_sold[i] = 1 let f = pht_fact(photo_st, PHOTO_SOLD, i) f.v = v f.mask = photo_st.pht_mask[i] } } return total } # what the roll would fetch now export function photo_worth(photo_st: PhotoState) -> int { var total = 0 for i in 0 .. photo_st.pht_n { total += photo_value(photo_st, i) } return total }