BankEvent = {};
BankEvent_mt = Class(BankEvent, Event);

InitEventClass(BankEvent, "BankEvent");

function BankEvent:emptyNew()
    local self = Event:new(BankEvent_mt);
    return self;
end;

function BankEvent:new(Bank)
    local self = BankEvent:emptyNew();
    return self;
end;

function BankEvent:readStreamAll(streamId, connection)
	
	g_currentMission.FarmingTablet.Bank.Kredit1.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.on = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.money = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.tage = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.tag = streamReadInt32(streamId);
	self:set(connection);
end;
function BankEvent:writeStreamAll(streamId, connection)
	
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.on);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.money);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.tage);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.tag);
end;
function BankEvent:set(connection)
	if not connection:getIsServer() then
		g_server:broadcastEvent(BankEvent:new(Bank));
	end;
end;
function BankEvent:readStream(streamId, connection)
	self:readStreamAll(streamId, connection);	
end;
function BankEvent:readUpdateStream(streamId, connection)
	self:readStreamAll(streamId, connection);
end;
function BankEvent:writeStream(streamId, connection)
	self:writeStreamAll(streamId, connection);	
end;
function BankEvent:writeUpdateStream(streamId, connection)
	self:writeStreamAll(streamId, connection);	
end; 

function BankEvent:sendEvent(Bank)
	g_client:getServerConnection():sendEvent(BankEvent:new(Bank));
end;

function BankEvent:run(connection)

end;