From 178c194e25896b80783d589b9912c926c07e3118 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sat, 20 Feb 2010 14:05:25 +0000 Subject: never singing a song two times in the same party session; counter reset if there are too few songs the medley-songs have their own counter git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2113 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UParty.pas | 4 + Game/Code/Classes/UPartyM2.pas | 3 +- Game/Code/Screens/UScreenSong.pas | 191 +++++++++++++++++++++++++++------- Game/Code/Screens/UScreenSongMenu.pas | 2 + 4 files changed, 164 insertions(+), 36 deletions(-) (limited to 'Game') diff --git a/Game/Code/Classes/UParty.pas b/Game/Code/Classes/UParty.pas index b57106a5..a843c393 100644 --- a/Game/Code/Classes/UParty.pas +++ b/Game/Code/Classes/UParty.pas @@ -167,6 +167,10 @@ begin Teams.Teaminfo[I].Joker := Round(NumRounds*0.7)+NumMedleys; Teams.Teaminfo[I].Score := 0; end; + + //Reset Played-array + SetLength(ScreenSong.MedleyPlayed, 0); + SetLength(ScreenSong.PartyPlayed, 0); end; //---------- diff --git a/Game/Code/Classes/UPartyM2.pas b/Game/Code/Classes/UPartyM2.pas index 8b7efced..d619c798 100644 --- a/Game/Code/Classes/UPartyM2.pas +++ b/Game/Code/Classes/UPartyM2.pas @@ -461,7 +461,8 @@ begin SetLength (Rounds, 0); //Reset SongsPlayed-Array - SetLength (PartySessionM2.SongsPlayed, 0); + SetLength(PartySessionM2.SongsPlayed, 0); + SetLength(ScreenSong.MedleyPlayed, 0); end; //---------- diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 51e6a1ee..bd4c7c87 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -78,6 +78,8 @@ type Mode: TSongMode; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show //2 = M2-Mode, 3=Medley-Mode PartyMedley: boolean; + PartyPlayed: array of integer; //played in Party Classic + MedleyPlayed: array of integer; //played in Challenge or Classic Medley-mode SungToEnd: boolean; //Song was sung to the end? @@ -160,6 +162,9 @@ type function getVisibleMedleyArr(MinS: TMedleySource): TVisArr; procedure StartMedley(num: integer; MinS: TMedleySource); procedure DrawAspect; + + function PartyPlayedSong(SongNr: integer): boolean; + function PartyPlayedMedley(SongNr: integer): boolean; end; implementation @@ -195,6 +200,40 @@ begin Result := Length(SkippedSongs); end; +function TScreenSong.PartyPlayedSong(SongNr: integer): boolean; +var + i: integer; + played :boolean; +begin + played := false; + for i := 0 to Length(PartyPlayed) - 1 do + begin + if (SongNr=PartyPlayed[i]) then + begin + played:=true; + break; + end; + end; + Result:=played; +end; + +function TScreenSong.PartyPlayedMedley(SongNr: integer): boolean; +var + i: integer; + played :boolean; +begin + played := false; + for i := 0 to Length(MedleyPlayed) - 1 do + begin + if (SongNr=MedleyPlayed[i]) then + begin + played:=true; + break; + end; + end; + Result:=played; +end; + //Show Wrong Song when Tabs on Fix procedure TScreenSong.FixSelected; var I, I2: Integer; @@ -583,10 +622,12 @@ begin VidVis := windowed; if (Ini.PartyPopup = 1) then ScreenSongMenu.MenuShow(SM_Party_Main) - else + else begin + SetLength(PartyPlayed, Length(PartyPlayed)+1); + PartyPlayed[Length(PartyPlayed)-1] := Interaction; ScreenSong.StartSong; - end else if (Mode = smChallenge) and (ChooseableSongs>0) and - not PartyMedley then //PartyMode M2 + end; + end else if (Mode = smChallenge) and not PartyMedley then begin PartySessionM2.AddSongPlayed(CatSongs.CatNumShow, Interaction); ScreenSong.StartSong; @@ -1253,7 +1294,8 @@ begin begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if CatSongs.Song[I].Visible and not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then + if CatSongs.Song[I].Visible and not PartyPlayedMedley(I) and + not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; @@ -1266,10 +1308,14 @@ begin begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if not CatSongs.Song[I].Main and not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then + if not CatSongs.Song[I].Main and not PartyPlayedMedley(I) and + not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then begin - SetLength(VisArr, Length(VisArr)+1); - VisArr[Length(VisArr)-1] := I; + if (PlaylistMan.Mode=0) or ((PlaylistMan.Mode<>0) and CatSongs.Song[I].Visible) then + begin + SetLength(VisArr, Length(VisArr)+1); + VisArr[Length(VisArr)-1] := I; + end; end; end; ChooseableSongs := Length(VisArr); @@ -1281,7 +1327,8 @@ begin begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if CatSongs.Song[I].Visible and not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then + if CatSongs.Song[I].Visible and not PartyPlayedMedley(I) and + not SongSkipped(I) and (CatSongs.Song[I].Medley.Source>=MinSource) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; @@ -1291,37 +1338,38 @@ begin Text[TextNumber].Text := IntToStr(Interaction+1) + '/' + IntToStr(Length(CatSongs.Song)) + ' (' + IntToStr(ChooseableSongs) + ')'; //HERE! end; - end else if (Mode=smParty) then + end else if (Mode=smParty) then//Party begin SetLength(VisArr, 0); if (CatSongs.CatNumShow = -2) then begin - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + - '/' + IntToStr(VS); + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS); end else if (CatSongs.CatNumShow = -3) then //Playlist! begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if CatSongs.Song[I].Visible and not SongSkipped(I) then + if CatSongs.Song[I].Visible and not PartyPlayedSong(I) and not SongSkipped(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; end; end; ChooseableSongs := Length(VisArr); - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + - '/' + IntToStr(VS) + + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + ' (' + IntToStr(ChooseableSongs) + ')'; //HERE! end else if (Ini.Tabs_at_startup = 1) then begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if not CatSongs.Song[I].Main and not SongSkipped(I) then + if not CatSongs.Song[I].Main and not PartyPlayedSong(I) and not SongSkipped(I) then begin - SetLength(VisArr, Length(VisArr)+1); - VisArr[Length(VisArr)-1] := I; + if (PlaylistMan.Mode=0) or ((PlaylistMan.Mode<>0) and CatSongs.Song[I].Visible) then + begin + SetLength(VisArr, Length(VisArr)+1); + VisArr[Length(VisArr)-1] := I; + end; end; end; ChooseableSongs := Length(VisArr); @@ -1333,7 +1381,7 @@ begin begin for I := 0 to Length(CatSongs.Song) - 1 do begin - if CatSongs.Song[I].Visible and not SongSkipped(I) then + if CatSongs.Song[I].Visible and not PartyPlayedSong(I) and not SongSkipped(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; @@ -1880,6 +1928,7 @@ begin end else begin if CatSongs.Song[I].Visible and not SongSkipped(I) and + not PartyPlayedMedley(I) and (CatSongs.Song[I].Medley.Source >= MinSource) then begin SetLength(VisArr, Length(VisArr)+1); @@ -2190,6 +2239,18 @@ begin begin while (not CatSongs.Song[(Interaction + Skip + Skip2) mod Length(Interactions)].Visible or (CatSongs.Song[(Interaction + Skip + Skip2) mod Length(Interactions)].Medley.Source < MinSource) or + PartyPlayedMedley((Interaction + Skip + Skip2) mod Length(Interactions)) or + SongSkipped((Interaction + Skip + Skip2) mod Length(Interactions))) do + begin + if not CatSongs.Song[(Interaction + Skip + Skip2) mod Length(Interactions)].Visible then + Inc(Skip) + else + Inc(Skip2); + end; + end else if (Mode=smParty) then + begin + while (not CatSongs.Song[(Interaction + Skip + Skip2) mod Length(Interactions)].Visible or + PartyPlayedSong((Interaction + Skip + Skip2) mod Length(Interactions)) or SongSkipped((Interaction + Skip + Skip2) mod Length(Interactions))) do begin if not CatSongs.Song[(Interaction + Skip + Skip2) mod Length(Interactions)].Visible then @@ -2488,6 +2549,16 @@ var VisArr: array of Integer; begin + if PartyMedley then + begin + if (Length(getVisibleMedleyArr(MinSource))<=0) then + SetLength(MedleyPlayed, 0); + end else + begin + if (CatSongs.VisibleSongs-Length(PartyPlayed)<=0) then + SetLength(PartyPlayed, 0); + end; + Case PlaylistMan.Mode of 0: //All Songs Just Select Random Song begin @@ -2499,14 +2570,14 @@ begin begin if not PartyMedley then begin - if not CatSongs.Song[I].Main and not SongSkipped(I)then + if not CatSongs.Song[I].Main and not SongSkipped(I) and not PartyPlayedSong(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; end; end else begin - if not CatSongs.Song[I].Main and not SongSkipped(I) and + if not CatSongs.Song[I].Main and not SongSkipped(I) and not PartyPlayedMedley(I) and (CatSongs.Song[I].Medley.Source >= MinSource) then begin SetLength(VisArr, Length(VisArr)+1); @@ -2550,14 +2621,14 @@ begin begin if not PartyMedley then begin - if not CatSongs.Song[I].Main and not SongSkipped(I)then + if not CatSongs.Song[I].Main and not SongSkipped(I) and not PartyPlayedSong(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; end; end else begin - if not CatSongs.Song[I].Main and not SongSkipped(I) and + if not CatSongs.Song[I].Main and not SongSkipped(I) and not PartyPlayedMedley(I) and (CatSongs.Song[I].Medley.Source >= MinSource) then begin SetLength(VisArr, Length(VisArr)+1); @@ -2592,14 +2663,14 @@ begin begin if not PartyMedley then begin - if CatSongs.Song[I].Visible and not SongSkipped(I)then + if CatSongs.Song[I].Visible and not SongSkipped(I) and not PartyPlayedSong(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; end; end else begin - if CatSongs.Song[I].Visible and not SongSkipped(I) and + if CatSongs.Song[I].Visible and not SongSkipped(I) and not PartyPlayedMedley(I) and (CatSongs.Song[I].Medley.Source >= MinSource) then begin SetLength(VisArr, Length(VisArr)+1); @@ -2631,14 +2702,14 @@ begin begin if not PartyMedley then begin - if CatSongs.Song[I].Visible and not SongSkipped(I)then + if CatSongs.Song[I].Visible and not SongSkipped(I) and not PartyPlayedSong(I) then begin SetLength(VisArr, Length(VisArr)+1); VisArr[Length(VisArr)-1] := I; end; end else begin - if CatSongs.Song[I].Visible and not SongSkipped(I) and + if CatSongs.Song[I].Visible and not SongSkipped(I) and not PartyPlayedMedley(I) and (CatSongs.Song[I].Medley.Source >= MinSource) then begin SetLength(VisArr, Length(VisArr)+1); @@ -2972,6 +3043,10 @@ begin SetLength(SkippedSongs, Length(SkippedSongs)+1); SkippedSongs[Length(SkippedSongs)-1] := Interaction; + + SetLength(PartyPlayed, Length(PartyPlayed)+1); + PartyPlayed[Length(PartyPlayed)-1] := Interaction; + SelectRandomSong; SetJoker; end; @@ -2985,6 +3060,9 @@ begin SetLength(SkippedSongs, Length(SkippedSongs)+1); SkippedSongs[Length(SkippedSongs)-1] := Interaction; + SetLength(MedleyPlayed, Length(MedleyPlayed)+1); + MedleyPlayed[Length(MedleyPlayed)-1] := Interaction; + SelectRandomSong; SetJoker; end; @@ -3000,6 +3078,9 @@ begin SetLength(SkippedSongs, Length(SkippedSongs)+1); SkippedSongs[Length(SkippedSongs)-1] := Interaction; + SetLength(MedleyPlayed, Length(MedleyPlayed)+1); + MedleyPlayed[Length(MedleyPlayed)-1] := Interaction; + SelectRandomSong; SetJoker; end; @@ -3046,12 +3127,26 @@ begin end; end; end else begin - for I := 0 to Length(CatSongs.Song) - 1 do + if PartyMedley then begin - if CatSongs.Song[I].Visible and (CatSongs.Song[I].Medley.Source >= MinS) then + for I := 0 to Length(CatSongs.Song) - 1 do begin - SetLength(res, Length(res)+1); - res[Length(res)-1] := I; + if CatSongs.Song[I].Visible and (CatSongs.Song[I].Medley.Source >= MinS) and not PartyPlayedMedley(I) + and not SongSkipped(I) then + begin + SetLength(res, Length(res)+1); + res[Length(res)-1] := I; + end; + end; + end else + begin + for I := 0 to Length(CatSongs.Song) - 1 do + begin + if CatSongs.Song[I].Visible and (CatSongs.Song[I].Medley.Source >= MinS) then + begin + SetLength(res, Length(res)+1); + res[Length(res)-1] := I; + end; end; end; end; @@ -3142,13 +3237,22 @@ begin SetLength(SkippedSongs, Length(SkippedSongs)+1); SkippedSongs[Length(SkippedSongs)-1] := Interaction; + SetLength(MedleyPlayed, Length(MedleyPlayed)+1); + MedleyPlayed[Length(MedleyPlayed)-1] := Interaction; + if ((Mode=smParty) and (PartySession.Rounds[PartySession.CurRound].MedleySurprise)) or ((Mode=smChallenge) and (PartySessionM2.Rounds[PartySessionM2.CurRound].MedleySurprise)) then begin VS := Length(getVisibleMedleyArr(MinS)); if VS < num then - PlaylistMedley.NumMedleySongs := VS - else + begin + SetLength(MedleyPlayed, 0); + VS := Length(getVisibleMedleyArr(MinS)); + if VS