package Data;

import java.util.List;

import engine.gridobject.person.Player;
import engine.item.Weapon;
import authoring.PlayerData;
import authoring.WorldData;

public class WorldDataManager {
	public WorldDataManager() {}
	
	public void saveMap(WorldData wd, String mapDataKey, Player player, String fileName) {
		WorldData worldData = wd;

        if (worldData == null)	 {
        	System.out.println("worldData is null");
        }
		PlayerData playerData = worldData.getMap(mapDataKey).getPlayData();		
		List<Weapon> wList = player.getWeaponList();
		System.out.println("weaponlist.size" + wList.size());
		String [] weaponListName = new String[wList.size()];
		int wCounter = 0;
		for (Weapon wep : wList) {
			String wepName = wep.toString();
			weaponListName[wCounter] = wepName;
			wCounter++;
		}
		
		worldData.getMap(mapDataKey).getPlayData().setWeapons(weaponListName);
		DataManager dm = new DataManager();
		dm.setWorldData(fileName, worldData);
		dm.saveWorldDataToFile(fileName);
	}
	

}

@@ -72,16 +72,41 @@
 Player;%0A
+import engine.item.Item;%0A
 import e
@@ -393,17 +393,16 @@
 == null)
-%09
  %7B%0A     
@@ -409,47 +409,14 @@
    %09
-System.out.println(%22worldData is null%22)
+return
 ;%0A  
@@ -549,58 +549,245 @@
 %0A%09%09S
-ystem.out.println(%22
+tring %5B%5D weaponListNames = new String%5BwList.size()%5D;%0A%09%09int wCounter = 0;%0A%09%09for (Weapon wep : wList) %7B%0A%09%09%09String wepName = wep.toString();%0A%09%09%09
 weapon
-list.size%22 + wList.size()
+ListNames%5BwCounter%5D = wepName;%0A%09%09%09wCounter++;%0A%09%09%7D%0A%09%09List%3CItem%3E itemList = player.getItems(
 );%0A%09
@@ -797,30 +797,28 @@
 ring %5B%5D 
-weapon
+item
 ListName
  = new S
@@ -809,16 +809,17 @@
 ListName
+s
  = new S
@@ -816,33 +816,36 @@
 es = new String%5B
-w
+item
 List.size()%5D;%0A%09%09
@@ -840,33 +840,33 @@
 .size()%5D;%0A%09%09int 
-w
+i
 Counter = 0;%0A%09%09f
@@ -865,38 +865,40 @@
 = 0;%0A%09%09for (
-Weapon wep : w
+Item item : item
 List) %7B%0A%09%09%09S
@@ -899,37 +899,39 @@
 %7B%0A%09%09%09String 
-wep
+item
 Name = 
-wep
+item
 .toString();
@@ -934,30 +934,28 @@
 g();%0A%09%09%09
-weapon
+item
 ListName
 %5BwCounte
@@ -946,18 +946,19 @@
 ListName
-%5Bw
+s%5Bi
 Counter%5D
@@ -952,35 +952,36 @@
 mes%5BiCounter%5D = 
-wep
+item
 Name;%0A%09%09%09wCounte
@@ -965,33 +965,33 @@
  = itemName;%0A%09%09%09
-w
+i
 Counter++;%0A%09%09%7D%0A%09
@@ -989,19 +989,16 @@
 ++;%0A%09%09%7D%0A
-%09%09%0A
 %09%09worldD
@@ -1055,24 +1055,95 @@
 aponListName
+s);%0A%09%09worldData.getMap(mapDataKey).getPlayData().setItems(itemListNames
 );%0A%09%09DataMan

Save items and weapons in PlayerData