Skip to content

Commit

Permalink
Give wallets merged access of all IDs inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
octareenroon91 committed Dec 4, 2015
1 parent c1ad583 commit f3f6136
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions code/game/objects/items/weapons/storage/wallets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,34 @@
slot_flags = SLOT_ID

var/obj/item/weapon/card/id/front_id = null
var/obj/item/weapon/card/id/net_id = null


/obj/item/weapon/storage/wallet/remove_from_storage(obj/item/W, atom/new_location)
/obj/item/weapon/storage/wallet/New()
..()
net_id = new /obj/item/weapon/card/id(src)

/obj/item/weapon/storage/wallet/remove_from_storage(obj/item/W as obj, atom/new_location)
. = ..(W, new_location)
if(.)
if(W == front_id)
front_id = null
if(istype(W, /obj/item/weapon/card/id))
refreshID()
update_icon()

/obj/item/weapon/storage/wallet/handle_item_insertion(obj/item/W, prevent_warning = 0)
/obj/item/weapon/storage/wallet/refreshID()
net_id.access.Cut()
for(var/obj/item/weapon/card/id/I in contents)
if(!front_id)
front_id = I
net_id.access |= I.access // Merge access from any and all cards in wallet

/obj/item/weapon/storage/wallet/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
. = ..(W, prevent_warning)
if(.)
if(!front_id && istype(W, /obj/item/weapon/card/id))
front_id = W
if(istype(W, /obj/item/weapon/card/id))
refreshID()
update_icon()

/obj/item/weapon/storage/wallet/update_icon()
Expand All @@ -66,12 +80,12 @@


/obj/item/weapon/storage/wallet/GetID()
return front_id
return front_id // net_id is only a holder for accesses.

/obj/item/weapon/storage/wallet/GetAccess()
var/obj/item/I = GetID()
if(I)
return I.GetAccess()
var/list/myaccess = net_id.GetAccess() // favor OOP by not using net_id.access directly.
if(myaccess.len) // is there any access to be had this way?
return myaccess
else
return ..()

Expand All @@ -89,4 +103,4 @@
if(item2_type)
new item2_type(src)
if(item3_type)
new item3_type(src)
new item3_type(src)

0 comments on commit f3f6136

Please sign in to comment.